home *** CD-ROM | disk | FTP | other *** search
/ Amiga Aktuell / Amiga Aktuell.iso / amiga-aktuell / net tools / fido net / ftsc-all-91 / fsc-0079.z02 / RTF-SPEC.005 < prev    next >
Text File  |  1995-03-03  |  321KB  |  8,380 lines

  1.  
  2.  
  3.  
  4.  
  5.        Microsoft(R) MS-DOS(R), WindowsO, OS/2(R), and        Microsoft(R)
  6.        Apple(R) Macintosh(R) Applications
  7.  
  8.        Version:  RTF Version 1.3
  9.                                                             Product Support
  10.                                                                Services
  11.  
  12.        Subject:  Rich Text Format (RTF) Specification an   Application Note
  13.                  Sample RTF Reader Program
  14.  
  15.  
  16.        Contents: 159 Pages, 1 Disk                           1/95 - GC0165
  17.  
  18.  
  19.         INFORMATION PROVIDED IN THIS DOCUMENT AND ANY SOFTWARE THAT MAY
  20.  
  21.  
  22.         EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
  23.         WARRANTIESROFIMERCHANTABILITYHAND/ORRFITNESSFFORYAKPARTICULARRation
  24.         PURPOSE. The user assumes the entire risk as to the accuracy and the
  25.         use of this Application Note. This Application Note may be copied and
  26.         distributed subject to the following conditions:  1) All text must be
  27.         copied without modification and all pages must be included;  2) If
  28.         software is included, all files on the disk(s) must be copied without
  29.         modification (the MS-DOS  utility diskcopy is appropriate for this
  30.         purpose);  3) All components of this Application Note must be
  31.         distributed together;  and  4) This Application Note may not be
  32.         distributed for profit.
  33.  
  34.         Copyright (c) 1989-1995 Microsoft Corporation.  All Rights Reserved.
  35.  
  36.         Microsoft, MS, MS-DOS, and Windows and are registered trademarks and
  37.                  Windows NT is a trademark of Microsoft Corporation.
  38.              PostScript is a registered trademark of Adobe Systems, Inc.
  39.             Apple, Macintosh, and TrueType are registered trademarks and
  40.                   QuickDraw is a trademark of Apple Computer, Inc.
  41.             IBM, OS/2, and Personal System/2 are registered trademarks of
  42.                     International Business Machines Corporation.
  43.              ITC Zapf Chancery is a registered trademark of International
  44.                                 Typeface Corporation.
  45.               Palatino is a registered trademark of Linotype AG and its
  46.                                     subsidiaries.
  47.          Arial, Courier New and Times New Roman are registered trademarks of
  48.                             The Monotype Corporation PLC.
  49.                   Unicode is a trademark of Unicode, Incorporated.
  50.  
  51.              This document was created using Microsoft Word for Windows.
  52.  
  53.  
  54.  
  55.                                   Table of Contents
  56.  
  57.  
  58.  
  59.        INTRODUCTION ........................................................5
  60.        RTF SYNTAX ..........................................................5
  61.        CONVENTIONS OF AN RTF READER ........................................8
  62.        FORMAL SYNTAX ......................................................10
  63.                          Microsoft Product Support Services
  64.  
  65.  
  66.                                                                       Page 2
  67.  
  68.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  69.  
  70.        CONTENTS OF AN RTF FILE ............................................11
  71.           Header ..........................................................11
  72.              RTF Version ..................................................11
  73.              Character Set ................................................11
  74.              Font Table ...................................................12
  75.                 Font Embedding ............................................14
  76.                 Code Page Support .........................................15
  77.              File Table ...................................................16
  78.              Color Table ..................................................17
  79.              Style Sheet ..................................................18
  80.              Revision Marks ...............................................20
  81.           Document Area ...................................................21
  82.              Information Group ............................................21
  83.              Document Formatting Properties ...............................24
  84.              Section Text .................................................30
  85.                 Section Formatting Properties .............................30
  86.                 Headers and Footers .......................................34
  87.              Paragraph Text ...............................................35
  88.                 Paragraph Formatting Properties ...........................35
  89.                 Tabs ......................................................37
  90.                 Bullets and Numbering .....................................38
  91.                 Paragraph Borders .........................................41
  92.                 Paragraph Shading .........................................42
  93.                 Positioned Objects and Frames .............................44
  94.                 Table Definitions .........................................46
  95.              Character Text ...............................................51
  96.                 Character Formatting Properties ...........................51
  97.                 Associated Character Properties ...........................56
  98.                 Special Characters ........................................58
  99.              Bookmarks ....................................................60
  100.              Pictures .....................................................61
  101.              Objects ......................................................66
  102.                 Macintosh Edition Manager Publisher Objects ...............70
  103.              Drawing Objects ..............................................70
  104.              Footnotes ....................................................79
  105.              Annotations ..................................................80
  106.              Fields .......................................................81
  107.              Index Entries ................................................83
  108.              Table of Contents Entries ....................................83
  109.              Bidirectional Language Support ...............................84
  110.  
  111.        APPENDIX A: SAMPLE RTF READER APPLICATION ..........................87
  112.           How to Write an RTF Reader ......................................87
  113.           A Sample RTF Reader Implementation ..............................88
  114.              RTFDECL.H and RTFREADR.C .....................................88
  115.              RTFTYPE.H ....................................................89
  116.              The RTFACTN.C File ...........................................91
  117.           Notes on Implementing Other RTF Features ........................92
  118.              Tabs and Other Control Sequences Terminating in a Fixed Control93
  119.              Borders and Other Control Sequences Beginning with a Fixed
  120.              Control ......................................................93
  121.           Other Problem Areas in RTF ......................................93
  122.              Style Sheets .................................................93
  123.  
  124.  
  125.  
  126.                          Microsoft Product Support Services
  127.  
  128.  
  129.                                                                       Page 3
  130.  
  131.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  132.  
  133.              Property Changes .............................................93
  134.              Fields .......................................................93
  135.              Tables .......................................................94
  136.           Appendix A-1: Listings ..........................................96
  137.              RTFDECL.H ....................................................96
  138.              RTFTYPE.H ....................................................97
  139.              RTFREADR.C ...................................................98
  140.              RTFACTN.C ...................................................104
  141.              MAKEFILE ....................................................111
  142.  
  143.  
  144.        APPENDIX B: WORD 6J RICH TEXT FORMAT ADDENDUM .....................113
  145.  
  146.  
  147.        APPENDIX C: INDEX OF RTF CONTROL WORDS ............................121
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.                          Microsoft Product Support Services
  190.  
  191.  
  192.                                                                       Page 5
  193.  
  194.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  195.  
  196.        INTRODUCTION
  197.  
  198.        The Rich Text Format (RTF) Specification is a method of encoding
  199.        formatted text and graphics for easy transfer between applications.
  200.        Currently, users depend on special translation software to move word-
  201.        processing documents between different MS-DOS, Windows, OS/2, and
  202.        Apple Macintosh applications.
  203.  
  204.        The RTF Specification provides a format for text and graphics
  205.        interchange that can be used with different output devices, operating
  206.        environments, and operating systems. RTF uses the ANSI, PC-8,
  207.        Macintosh, or IBM(R) PC character set to control the representation
  208.        and formatting of a document, both on the screen and in print. With
  209.        the RTF Specification, documents created under different operating
  210.        systems and with different software applications can be transferred
  211.        between those operating systems and applications.
  212.  
  213.        Software that takes a formatted file and turns it into an RTF file is
  214.        called a writer. An RTF writer separates the application's control
  215.        information from the actual text and writes a new file containing the
  216.        text and the RTF groups associated with that text. Software that
  217.        translates an RTF file into a formatted file is called a reader.
  218.  
  219.        Included with the RTF specification is a sample RTF reader application
  220.        (see "Appendix A: Sample RTF Reader Application" beginning on page
  221.        87). It is designed for use with the specification to assist those
  222.        users developing their own RTF readers. The GC0165 disk included with
  223.        this Application Note contains RTFREADR.EXE, the sample RTF reader
  224.        program itself. This file and its use are described in Appendix A. The
  225.        sample RTF reader is not a for-sale product, and Microsoft does not
  226.        provide technical or any other type of support for the sample RTF
  227.        reader code or the RTF specification.
  228.  
  229.        RTF SYNTAX
  230.  
  231.        An RTF file consists of unformatted text, control words, control
  232.        symbols, and groups. For ease of transport, a standard RTF file can
  233.        consist of only 7-bit ASCII characters. (Converters that communicate
  234.        with Microsoft Word for Windows or Microsoft Word for the Macintosh
  235.        should expect 8-bit characters.)
  236.  
  237.        A control word is a specially formatted command that RTF uses to mark
  238.        printer control codes and information that applications use to manage
  239.        documents. A control word takes the following form:
  240.  
  241.          \LetterSequence<Delimiter>
  242.  
  243.        Note that a backslash begins each control word.
  244.  
  245.        The LetterSequence is made up of lowercase alphabetic characters
  246.        between "a" and "z" inclusive. RTF is case sensitive, and all RTF
  247.        control words must be in lowercase.
  248.  
  249.  
  250.  
  251.  
  252.                          Microsoft Product Support Services
  253.  
  254.  
  255.                                                                       Page 6
  256.  
  257.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  258.  
  259.        The Delimiter marks the end of an RTF control word, and can be one of
  260.        the following:
  261.  
  262.        .  A space. In this case, the space is part of the control word.
  263.  
  264.        .  A digit or a hyphen (-), which indicates that a numeric parameter
  265.           follows. The subsequent digital sequence is then delimited by a
  266.           space or any character other than a letter or a digit. The
  267.           parameter can be a positive or a negative number. The range of the
  268.           values for the number is -32767 through 32767. However, Microsoft
  269.           Word for Windows, Word for OS/2, and Word for the Macintosh
  270.           restrict the range to -31680 through 31680. If a numeric parameter
  271.           immediately follows the control word, this parameter becomes part
  272.           of the control word. The control word is then delimited by a space
  273.           or a nonalphabetic or nonnumeric character in the same manner as
  274.           any other control word.
  275.  
  276.        .  Any character other than a letter or a digit. In this case, the
  277.           delimiting character terminates the control word but is not
  278.           actually part of the control word.
  279.  
  280.        If a space delimits the control word, the space does not appear in the
  281.        document. Any characters following the delimiter, including spaces,
  282.        will appear in the document. For this reason, you should use spaces
  283.        only where necessary; do not use spaces merely to break up RTF code.
  284.  
  285.        A control symbol consists of a backslash followed by a single,
  286.        nonalphabetic character. For example, \~ represents a nonbreaking
  287.        space. Control symbols take no delimiters.
  288.  
  289.        A group consists of text and control words or control symbols enclosed
  290.        in braces ({ }). The opening brace ({ ) indicates the start of the
  291.        group and the closing brace ( }) indicates the end of the group. Each
  292.        group specifies the text affected by the group and the different
  293.        attributes of that text. The RTF file can also include groups for
  294.        fonts, styles, screen color, pictures, footnotes, annotations, headers
  295.        and footers, summary information, fields, and bookmarks, as well as
  296.        document-, section-, paragraph-, and character-formatting properties.
  297.        If the font, file, style, screen-color, revision mark, and summary-
  298.        information groups and document-formatting properties are included,
  299.        they must precede the first plain-text character in the document.
  300.        These groups form the RTF file header. If the group for fonts is
  301.        included, it should precede the group for styles. If any group is not
  302.        used, it can be omitted. The groups are discussed in the following
  303.        sections.
  304.  
  305.        The control properties of certain control words (such as bold, italic,
  306.        keep together, and so forth) have only two states. When such a control
  307.        word has no parameter or has a nonzero parameter, it is assumed that
  308.        the control word turns on the property. When such a control word has a
  309.        parameter of 0 (zero), it is assumed that the control word turns off
  310.        the property. For example, \b turns on bold, whereas \b0 turns off
  311.  
  312.  
  313.  
  314.  
  315.                          Microsoft Product Support Services
  316.  
  317.  
  318.                                                                       Page 7
  319.  
  320.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  321.  
  322.        bold.
  323.  
  324.        Certain control words, referred to as destinations, mark the beginning
  325.        of a collection of related text that could appear at another position,
  326.        or destination, within the document. Destinations may also be text
  327.        that is used but should not appear within the document at all. An
  328.        example of a destination is the \footnote group, where the footnote
  329.        text follows the control word. Destination control words and their
  330.        following text must be enclosed in braces. Destinations added after
  331.        the RTF Specification published in the March 1987 Microsoft Systems
  332.        Journal may be preceded by the control symbol \*. This control symbol
  333.        identifies destinations whose related text should be ignored if the
  334.        RTF reader does not recognize the destination. (RTF writers should
  335.        follow the convention of using this control symbol when adding new
  336.        destinations or groups.) Destinations whose related text should be
  337.        inserted into the document even if the RTF reader does not recognize
  338.        the destination should not use \*. All destinations that were not
  339.        included in the March 1987 revision of the RTF Specification are shown
  340.        with \* as part of the control word.
  341.  
  342.        Formatting specified within a group affects only the text within that
  343.        group. Generally, text within a group inherits the formatting of the
  344.        text in the preceding group. However, Microsoft implementations of RTF
  345.        assume that the footnote, annotation, header, and footer groups
  346.        (described later in this chapter) do not inherit the formatting of the
  347.        preceding text. Therefore, to ensure that these groups are always
  348.        formatted correctly, you should set the formatting within these groups
  349.        to the default with the \sectd, \pard, and \plain control words, and
  350.        then add any desired formatting.
  351.  
  352.        The control words, control symbols, and braces constitute control
  353.        information. All other characters in the file are plain text. Here is
  354.        an example of plain text that does not exist within a group:
  355.  
  356.           {\rtf\ansi\deff0{\fonttbl{\f0\froman Tms Rmn;}{\f1\fdecor
  357.  
  358.           Symbol;}{\f2\fswiss Helv;}}{\colortbl;\red0\green0\blue0;
  359.  
  360.           \red0\green0\blue255;\red0\green255\blue255;\red0\green255\
  361.  
  362.           blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\
  363.  
  364.           green255\blue0;\red255\green255\blue255;}{\stylesheet{\fs20
  365.           \snext0Normal;}}{\info{\author John Doe}
  366.  
  367.           {\creatim\yr1990\mo7\dy30\hr10\min48}{\version1}{\edmins0}
  368.  
  369.           {\nofpages1}{\nofwords0}{\nofchars0}{\vern8351}}\widoctrl\ftnbj
  370.           \sectd\linex0\endnhere \pard\plain \fs20 This is plain text.\par}
  371.  
  372.  
  373.  
  374.        The phrase ``This is plain text'' is not part of a group and is
  375.  
  376.  
  377.  
  378.                          Microsoft Product Support Services
  379.  
  380.  
  381.                                                                       Page 8
  382.  
  383.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  384.  
  385.        treated as document text.
  386.  
  387.        As previously mentioned, the backslash ( \ ) and braces ({ }) have
  388.        special meaning in RTF. To use these characters as text, precede them
  389.        with a backslash, as in \, \{, and \}.
  390.  
  391.        CONVENTIONS OF AN RTF READER
  392.  
  393.        The reader of an RTF stream is concerned with the following:
  394.  
  395.        .  Separating control information from plain text.
  396.  
  397.        .  Acting on control information.
  398.  
  399.        .  Collecting and properly inserting text into the document, as
  400.           directed by the current group state.
  401.  
  402.        Acting on control information is designed to be a relatively simple
  403.        process. Some control information simply contributes special
  404.        characters to the plain text stream. Other information serves to
  405.        change the program state, which includes properties of the document as
  406.        a whole, or to change any of a collection of group states, which apply
  407.        to parts of the document.
  408.  
  409.        As previously mentioned, a group state can specify the following:
  410.  
  411.        .  The destination, or part of the document that the plain text is
  412.           constructing.
  413.  
  414.        .  Character-formatting properties, such as bold or italic.
  415.  
  416.        .  Paragraph-formatting properties, such as justified or centered.
  417.  
  418.        .  Section-formatting properties, such as the number of columns.
  419.  
  420.        .  Table-formatting properties, which define the number of cells and
  421.           dimensions of a table row.
  422.  
  423.        In practice, an RTF reader will evaluate each character it reads in
  424.        sequence as follows:
  425.  
  426.        .  If the character is an opening brace ({), the reader stores its
  427.           current state on the stack. If the character is a closing brace
  428.           (}), the reader retrieves the current state from the stack.
  429.  
  430.        .  If the character is a backslash (\), the reader collects the
  431.           control word or control symbol and its parameter, if any, and looks
  432.           up the control word or control symbol in a table that maps control
  433.           words to actions. It then carries out the action prescribed in the
  434.           table. (The possible actions are discussed below.) The read pointer
  435.           is left before or after a control-word delimiter, as appropriate.
  436.  
  437.        .  If the character is anything other than an opening brace ({),
  438.  
  439.  
  440.  
  441.                          Microsoft Product Support Services
  442.  
  443.  
  444.                                                                       Page 9
  445.  
  446.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  447.  
  448.           closing brace (}), or backslash (\) , the reader assumes that the
  449.           character is plain text and writes the character to the current
  450.           destination using the current formatting properties.
  451.  
  452.        If the RTF reader cannot find a particular control word or control
  453.        symbol in the look-up table described above, the control word or
  454.        control symbol should be ignored. If a control word or control symbol
  455.        is preceded by an opening brace ({), it is part of a group. The
  456.        current state should be saved on the stack, but no state change should
  457.        occur. When a closing brace (}) is encountered, the current state
  458.        should be retrieved from the stack, thereby resetting the current
  459.        state. If the \* control symbol precedes a control word, then it
  460.        defines a destination group and was itself preceded by an opening
  461.        brace ({). The RTF reader should discard all text up to and including
  462.        the closing brace (}) that closes this group. All RTF readers must
  463.        recognize all destinations defined in the March 1987 RTF
  464.        Specification. The reader may skip past the group, but it is not
  465.        allowed to simply discard the control word. Destinations defined since
  466.        March 1987 are marked with the \* control symbol.
  467.  
  468.           Note: All RTF readers must implement the \* control symbol so that
  469.           they can read RTF files written by newer RTF writers.
  470.  
  471.        For control words or control symbols that the RTF reader can find in
  472.        the look-up table, the possible actions are as follows.
  473.  
  474.           Action              Description
  475.           ------------------- -----------------------------------------------
  476.           Change Destination  The RTF reader changes the destination to the
  477.                               destination described in the table entry.
  478.                               Destination changes are legal only immediately
  479.                               after an opening brace ({ ). (Other
  480.                               restrictions may also apply; for example,
  481.                               footnotes cannot be nested.) Many destination
  482.                               changes imply that the current property
  483.                               settings will be reset to their default
  484.                               settings. Examples of control words that change
  485.                               destination are \footnote, \header, \footer,
  486.                               \pict, \info, \fonttbl, \stylesheet, and
  487.                               \colortbl. This Application Note identifies all
  488.                               destination control words where they appear in
  489.                               control-word tables.
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.                          Microsoft Product Support Services
  505.  
  506.  
  507.                                                                      Page 10
  508.  
  509.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  510.  
  511.           Action              Description
  512.           ------------------- -----------------------------------------------
  513.           Change Formatting   The RTF reader changes the property as
  514.           Property            described in the table entry. The entry will
  515.                               specify whether a parameter is required. The
  516.                               ``APPENDIX C: INDEX OF RTF CONTROL WORDS''
  517.                               section at the end of this Application Note
  518.                               also specifies which control words require
  519.                               parameters. If a parameter is needed and not
  520.                               specified, then a default value will be used.
  521.                               The default value used depends on  the control
  522.                               word. If the control word does not specify a
  523.                               default, then all RTF readers should assume a
  524.                               default of 0.
  525.  
  526.           Insert Special      The reader inserts into the document the
  527.           Character           character code or codes described in the table
  528.                               entry.
  529.  
  530.           Insert Special      The reader inserts into the document the
  531.           Character and       character code or codes described in the table
  532.           Perform Action      entry and performs whatever other action the
  533.                               entry specifies. For example, when Microsoft
  534.                               Word interprets \par, a paragraph mark is
  535.                               inserted in the document and special code is
  536.                               run to record the paragraph properties
  537.                               belonging to that paragraph mark.
  538.  
  539.        FORMAL SYNTAX
  540.  
  541.        This Application Note describes RTF using the following syntax, based
  542.        on Backus-Naur Form.
  543.  
  544.           Syntax      Meaning
  545.           ----------- ------------------------------------------------------
  546.           #PCDATA     Text (without control words).
  547.  
  548.           #SDATA      Hexadecimal data.
  549.  
  550.           #BDATA      Binary data.
  551.  
  552.           'c'         A literal.
  553.  
  554.           <text>      A nonterminal.
  555.  
  556.           a           The (terminal) control word a, without a parameter.
  557.  
  558.           a  or aN    The (terminal) control word a, with a parameter.
  559.  
  560.           a?          Item a is optional.
  561.  
  562.           a+          One or more repetitions of item a.
  563.  
  564.  
  565.  
  566.  
  567.                          Microsoft Product Support Services
  568.  
  569.  
  570.                                                                      Page 11
  571.  
  572.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  573.  
  574.           Syntax      Meaning
  575.           ----------- ------------------------------------------------------
  576.           a*          Zero or more repetitions of item a.
  577.  
  578.           a b         Item a followed by item b.
  579.  
  580.           a | b       Item a or item b.
  581.  
  582.           a & b       Item a and/or item b, in any order.
  583.  
  584.        CONTENTS OF AN RTF FILE
  585.  
  586.        An RTF file has the following syntax:
  587.  
  588.           <File>      '{' <header> <document>'}'
  589.  
  590.        This syntax is the standard RTF syntax; any RTF reader must be able to
  591.        correctly interpret RTF written to this syntax. It is worth mentioning
  592.        again that RTF readers do not have to use all control words, but they
  593.        must be able to harmlessly ignore unknown (or unused) control words,
  594.        and they must correctly skip over destinations marked with the \*
  595.        control symbol. There may, however, be RTF writers that generate RTF
  596.        that does not conform to this syntax, and as such, RTF readers should
  597.        be robust enough to handle some minor variations. Nonetheless, if an
  598.        RTF writer generates RTF conforming to this specification, then any
  599.        correct RTF reader should be able to interpret it.
  600.  
  601.        Header
  602.  
  603.        The header has the following syntax:
  604.  
  605.           <header>    \rtf <charset> \deff? <fonttbl> <filetbl>? <colortbl>?
  606.                       <stylesheet>? <revtbl>?
  607.  
  608.        RTF Version
  609.  
  610.        An entire RTF file is considered a group and must be enclosed in
  611.        braces. The control word \rtfN must follow the opening brace. The
  612.        numeric parameter N identifies the major version of the RTF
  613.        Specification used. The RTF standard described in this Application
  614.        Note, although titled as version 1.2, continues to correspond
  615.        syntactically to RTF Specification Version 1. Therefore, the numeric
  616.        parameter N for the \rtf control word should still be emitted as 1.
  617.  
  618.        Character Set
  619.  
  620.        After specifying the RTF version, you must declare the character set
  621.        used in this document. The control word for the character set must
  622.        precede any plain text or any table control words. The RTF
  623.        Specification currently supports the following character sets.
  624.  
  625.  
  626.  
  627.  
  628.  
  629.  
  630.                          Microsoft Product Support Services
  631.  
  632.  
  633.                                                                      Page 12
  634.  
  635.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  636.  
  637.           Control word Character set
  638.           ------------ ------------------------------------------------------
  639.           \ansi        ANSI (the default)
  640.  
  641.           \mac         Apple Macintosh
  642.  
  643.           \pc          IBM PC code page 437
  644.  
  645.           \pca         IBM PC code page 850, used by IBM Personal System/2(R)
  646.                        (not implemented in version 1 of Microsoft Word for
  647.                        OS/2)
  648.  
  649.        Font Table
  650.  
  651.        The \fonttbl control word introduces the font table group. Unique \fN
  652.        control words define each font available in the document, and are used
  653.        to reference that font throughout the document. This group has the
  654.        following syntax:
  655.  
  656.           <fonttbl>   '{' \fonttbl (<fontinfo> | ('{' <fontinfo> '}'))+  '}'
  657.  
  658.           <fontinfo>  <fontnum><fontfamily><fcharset>?<fprq>?<fontemb>?<code
  659.                       age>? <fontname><fontaltname>? ';'
  660.  
  661.           <fontnum>   \f
  662.  
  663.           <fontfamily \fnil | \froman | \fswiss | \fmodern | \fscript |
  664.                       \fdecor | \ftech | \fbidi
  665.  
  666.           <fcharset>  \fcharset
  667.  
  668.           <fprq>      \fprq
  669.  
  670.           <fontname>  #PCDATA
  671.  
  672.           <fontaltnam '{\*' \falt #PCDATA '}'
  673.           >
  674.  
  675.           <fontemb>   '{\*' \fontemb <fonttype> <fontfname>? <data>? '}'
  676.  
  677.           <fonttype>  \ftnil | \fttruetype
  678.  
  679.           <fontfname> '{\*' \fontfile <codepage>? #PCDATA '}'
  680.  
  681.           <codepage>  \cpg
  682.  
  683.        Note for <fontemb> that either <fontfname> or <data> must be present,
  684.        although both may be present.
  685.  
  686.        All fonts available to the RTF writer can be included in the font
  687.        table, even if the document doesn't use all the fonts.
  688.  
  689.        RTF also supports font families, so that applications can attempt to
  690.  
  691.  
  692.  
  693.                          Microsoft Product Support Services
  694.  
  695.  
  696.                                                                      Page 13
  697.  
  698.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  699.  
  700.        intelligently choose fonts if the exact font is not present on the
  701.        reading system. RTF uses the following control words to describe the
  702.        various font families.
  703.  
  704.           Control word Font family                  Examples
  705.           ------------ --------------------------------------------------
  706.           \fnil        Unknown or default fonts (the
  707.                        default)
  708.  
  709.           \froman      Roman, proportionally spaced Times New Roman(R),
  710.                        serif fonts                  Palatino(R)
  711.  
  712.           \fswiss      Swiss, proportionally spaced Arial(R)
  713.                        sans serif fonts
  714.  
  715.           \fmodern     Fixed-pitch serif and sans   Courier New(R), Pica
  716.                        serif fonts
  717.  
  718.           \fscript     Script fonts                 Cursive
  719.  
  720.           \fdecor      Decorative fonts             Old English, ITC Zapf
  721.                                                     Chancery(R)
  722.  
  723.           \ftech       Technical, symbol, and       Symbol
  724.                        mathematical fonts
  725.  
  726.           \fbidi       Arabic, Hebrew, or other     Miriam
  727.                        bidirectional font
  728.  
  729.        If an RTF file uses a default font, the default font number is
  730.        specified with the \deffN control word, which must precede the font-
  731.        table group. The RTF writer supplies the default font number used in
  732.        the creation of the document as the numeric argument N. The RTF reader
  733.        then translates this number through the font table into the most
  734.        similar font available on the reader's system.
  735.  
  736.        The following control words specify the character set, alternative
  737.        font name and pitch of a font in the font table.
  738.  
  739.           Control word Definition
  740.           ------------ -----------------------------------------------------
  741.           \fcharsetN   Specifies the character set of a font in the font
  742.                        table.
  743.  
  744.           \falt        Indicates alternate font name to use if the specified
  745.                        font in the font table is not available.  '{\*' \falt
  746.                        <Alternate Font Name>'}'
  747.  
  748.           \fprqN       Specifies the pitch of a font in the font table.
  749.  
  750.        If \fcharset is specified, the N argument can be one of the following
  751.        types.
  752.  
  753.  
  754.  
  755.  
  756.                          Microsoft Product Support Services
  757.  
  758.  
  759.                                                                      Page 14
  760.  
  761.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  762.  
  763.           Character set            N Value
  764.           ------------------------ -----------------------------------------
  765.           ANSI_CHARSET              0
  766.  
  767.           SYMBOL_CHARSET            2
  768.  
  769.           SHIFTJIS_CHARSET          128
  770.  
  771.           GREEK_CHARSET             161
  772.  
  773.           TURKISH_CHARSET           162
  774.  
  775.           HEBREW_CHARSET            177
  776.  
  777.           ARABICSIMPLIFIED_CHARSET  178
  778.  
  779.           ARABICTRADITIONAL_CHARSET 179
  780.  
  781.           ARABICUSER_CHARSET        180
  782.  
  783.           HEBREWUSER_CHARSET        181
  784.  
  785.           CYRILLIC_CHARSET          204
  786.  
  787.           EASTERNEUROPE_CHARSET     238
  788.  
  789.           PC437_CHARSET              254
  790.  
  791.           OEM_CHARSET                255
  792.  
  793.        If \fprq is specified, the N argument can be one of the following
  794.        values.
  795.  
  796.           Pitch       Value
  797.           ----------- ------------------------------------------------------
  798.           Default     0
  799.           pitch
  800.  
  801.           Fixed pitch 1
  802.  
  803.           Variable    2
  804.           pitch
  805.  
  806.        Font Embedding
  807.  
  808.        RTF supports embedded fonts with the \fontemb group located inside a
  809.        font definition. An embedded font can be specified by a filename, or
  810.        the actual font data may be located inside the group. If a filename is
  811.        specified, it is contained in the \fontfile group. The \cpg control
  812.        word can be used to specify the character set for the filename.
  813.  
  814.        RTF supports TrueTypeO and other embedded fonts. The type of the
  815.  
  816.  
  817.  
  818.  
  819.                          Microsoft Product Support Services
  820.  
  821.  
  822.                                                                      Page 15
  823.  
  824.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  825.  
  826.        embedded font is described by the following control words.
  827.  
  828.           Control word Embedded font type
  829.           ------------ -----------------------------------------------------
  830.           \ftnil       Unknown or default font type (the default)
  831.  
  832.           \fttruetype  TrueType font
  833.  
  834.        Code Page Support
  835.  
  836.        A font may have a different character set from the character set of
  837.        the document. For example, the Symbol font has the same characters in
  838.        the same positions both on the Macintosh and in Windows. RTF describes
  839.        this with the \cpg control word, which names the character set used by
  840.        the font. In addition, filenames (used in field instructions and in
  841.        embedded fonts) may not necessarily be the same as the character set
  842.        of the document; the \cpg control word can change the character set
  843.        for these filenames as well. However, all RTF documents must still
  844.        declare a character set (that is, \ansi, \mac, \pc, or \pca) to
  845.        maintain backwards compatibility with earlier RTF readers.
  846.  
  847.        The table below describes valid values for \cpg.
  848.  
  849.           Value       Description
  850.           ----------- ------------------------------------------------------
  851.           437         United States IBM
  852.  
  853.           708         Arabic (ASMO 708)
  854.  
  855.           709         Arabic (ASMO 449+, BCON V4)
  856.  
  857.           710         Arabic (transparent Arabic)
  858.  
  859.           711         Arabic (Nafitha Enhanced)
  860.  
  861.           720         Arabic (transparent ASMO)
  862.  
  863.           819         Windows 3.1 (United States and Western Europe)
  864.  
  865.           850         IBM multilingual
  866.  
  867.           852         Eastern European
  868.  
  869.           860         Portuguese
  870.  
  871.           862         Hebrew
  872.  
  873.           863         French Canadian
  874.  
  875.           864         Arabic
  876.  
  877.           865         Norwegian
  878.  
  879.  
  880.  
  881.  
  882.                          Microsoft Product Support Services
  883.  
  884.  
  885.                                                                      Page 16
  886.  
  887.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  888.  
  889.           Value       Description
  890.           ----------- ------------------------------------------------------
  891.           866         Soviet Union
  892.  
  893.           932         Japanese
  894.  
  895.           1250        Windows 3.1 (Eastern European)
  896.  
  897.           1251        Windows 3.1 (Cyrillic)
  898.  
  899.        File Table
  900.  
  901.        The \filetbl control word introduces the file table destination. This
  902.        group defines the files referenced in the document and has the
  903.        following syntax:
  904.  
  905.           <filetbl>   '{\*'  \filetbl ('{' <fileinfo> '}')+  '}'
  906.  
  907.           <fileinfo>  \file <filenum><relpath>?<osnum>? <filesource>+
  908.                       <filename>
  909.  
  910.           <filenum>    \fid
  911.  
  912.           <relpath>   \frelative
  913.  
  914.           <osnum>     \fosnum
  915.  
  916.           <filesource  \fvalidmac | \fvaliddos | \fvalidntfs | \fvalidhpfs |
  917.                       \fnetwork
  918.  
  919.           <filename>  #PCDATA
  920.  
  921.        Note that the filename can be any valid alphanumeric string for the
  922.        named file system, indicating the complete path and filename.
  923.  
  924.           Control word Definition
  925.           ------------ -----------------------------------------------------
  926.           \filetbl     A list of documents referenced by the current
  927.                        document. The file table has a structure analogous to
  928.                        the style or font table. This is a destination control
  929.                        word output as part of the document header.
  930.  
  931.           \file        Marks the beginning of a file group, which lists
  932.                        relevant information about the referenced file. This
  933.                        is a destination control word.
  934.  
  935.           \fidN        File ID number. Files are referenced later in the
  936.                        document using this number.
  937.  
  938.  
  939.  
  940.  
  941.  
  942.  
  943.  
  944.  
  945.                          Microsoft Product Support Services
  946.  
  947.  
  948.                                                                      Page 17
  949.  
  950.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  951.  
  952.           Control word Definition
  953.           ------------ -----------------------------------------------------
  954.           \frelativeN  The character position within the path (starting at 0
  955.                        [zero]) where the referenced file's path starts to be
  956.                        relative to the path of the owning document. For
  957.                        example, a document is saved to the path
  958.                        C:\PRIVATE\RESUME\FILE1.DOC and its file table
  959.                        contains the path C:\PRIVATE\RESUME\EDU\FILE2.DOC,
  960.                        then that entry in the file table will be
  961.                        \frelative18, to point at the character "e" in "edu".
  962.                        This allows preservation of relative paths.
  963.  
  964.           \fosnumN     Currently only filled in for paths from the Macintosh
  965.                        file system. It is an operating-system-specific number
  966.                        for identifying the file, which may be used to speed
  967.                        up access to the file, or find it if the file has been
  968.                        moved to another folder or disk. The Macintosh
  969.                        operating system name for this number is the "file
  970.                        id." Additional meanings of the \fosnumN control word
  971.                        may be defined for other file systems in the future.
  972.  
  973.           \fvalidmac   Macintosh file system.
  974.  
  975.           \fvaliddos   MS-DOS file system.
  976.  
  977.           \fvalidntfs  NTFS file system.
  978.  
  979.           \fvalidhpfs  HPFS file system.
  980.  
  981.           \fnetwork    Network file system. This control word may be used in
  982.                        conjunction with any of the previous file source
  983.                        control words.
  984.  
  985.        Color Table
  986.  
  987.        The \colortbl control word introduces the color table group, which
  988.        defines screen colors, character colors, and other color information.
  989.        This group has the following syntax:
  990.  
  991.           <colortbl>  '{' \colortbl <colordef>+ '}'
  992.  
  993.           <colordef>  \red ? & \green ? & \blue ? ';'
  994.  
  995.        The following are valid control words for this group.
  996.  
  997.           Control word Meaning
  998.           ------------ -----------------------------------------------------
  999.           \redN        Red index
  1000.  
  1001.           \greenN      Green index
  1002.  
  1003.           \blueN       Blue index
  1004.  
  1005.  
  1006.  
  1007.  
  1008.                          Microsoft Product Support Services
  1009.  
  1010.  
  1011.                                                                      Page 18
  1012.  
  1013.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  1014.  
  1015.        Each definition must be delimited by a semicolon, even if the
  1016.        definition is omitted. If a color definition is omitted, the RTF
  1017.        reader uses its default color. In the example below, three colors are
  1018.        defined. The first color is omitted, as shown by the semicolon
  1019.        following the \colortbl control word.
  1020.  
  1021.           {\colortbl;\red0\green0\blue0;\red0\green0\blue255;}
  1022.  
  1023.  
  1024.  
  1025.        The foreground and background colors use indexes into the color table
  1026.        to define a color. For more information on color setup, see your
  1027.        Windows documentation.
  1028.  
  1029.        The following example defines a block of text in color (where
  1030.        supported). Note that the cf/cb index is the index of an entry in the
  1031.        color table, which represents a red/green/blue color combination.
  1032.  
  1033.           {\f1\cb1\cf2 This is colored text. The background is color
  1034.           1 and the foreground is color 2.}
  1035.  
  1036.  
  1037.  
  1038.        If the file is translated for software that does not display color,
  1039.        the reader ignores the color-table group.
  1040.  
  1041.        Style Sheet
  1042.  
  1043.        The \stylesheet control word introduces the style sheet group, which
  1044.        contains definitions and descriptions of the various styles used in
  1045.        the document. All styles in the document's style sheet can be
  1046.        included, even if not all the styles are used. In RTF, a style is a
  1047.        form of shorthand used to specify a set of character, paragraph, or
  1048.        section formatting.
  1049.  
  1050.        The style-sheet group has the following syntax:
  1051.  
  1052.           <stylesheet '{' \stylesheet <style>+ '}'
  1053.  
  1054.           <style>     '{' <styledef>?<keycode>? <formatting> <additive>?
  1055.                       <based>? <next>? <stylename>? ';' '}'
  1056.  
  1057.           <styledef>  \s  | \cs  | \ds
  1058.  
  1059.           <keycode>   '{' \keycode <keys> '}'
  1060.  
  1061.           <additive>  \additive
  1062.  
  1063.           <based>     \sbasedon
  1064.  
  1065.           <next>      \snext
  1066.  
  1067.  
  1068.  
  1069.  
  1070.  
  1071.                          Microsoft Product Support Services
  1072.  
  1073.  
  1074.                                                                      Page 19
  1075.  
  1076.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  1077.  
  1078.           <formatting (<brdrdef> | <parfmt> | <apoctl> | <tabdef> | <shading
  1079.                       | <chrfmt>)+
  1080.  
  1081.           <stylename> #PCDATA
  1082.  
  1083.           <keys>      ( \shift? & \ctrl? & \alt?) <key>
  1084.  
  1085.           <key>       \fn | #PCDATA
  1086.  
  1087.        For <style>, both <styledef> and <stylename> are optional; the default
  1088.        is paragraph style 0. Note for <stylename> that Microsoft Word for the
  1089.        Macintosh interprets commas in #PCDATA as separating style synonyms.
  1090.        Also, for <key>, the data must be exactly one character.
  1091.  
  1092.           Control wordMeaning
  1093.           ------------------------------------------------------------------
  1094.           \csN        Designates character style.
  1095.  
  1096.           \sN         Designates paragraph style.
  1097.  
  1098.           \dsN        Designates section style.
  1099.  
  1100.           \additive   Used in a character style definition ('{\*'\cs/'}').
  1101.                       Indicates that style attributes are to be applied in
  1102.                       addition to current attributes, rather than setting th
  1103.                       character attributes to only the style definition.
  1104.  
  1105.           \sbasedonN  Defines the number of the style on which the current
  1106.                       style is based (the default is 222--no style).
  1107.  
  1108.           \snextN     Defines the next style associated with the current
  1109.                       style; if omitted, the next style is the current style
  1110.  
  1111.           \keycode    This group is specified within the description of a
  1112.                       style in the style sheet in the RTF header. The syntax
  1113.                       for this group is '{\*'\keycode <keys>'}' where <keys>
  1114.                       are the characters used in the key code. For example,
  1115.                       style, Normal, may be defined {\s0 {\*\keycode
  1116.                       \shift\ctrl n}Normal;} within the RTF style sheet. See
  1117.                       the Special Character control words for the characters
  1118.                       outside the alphanumeric range that may be used.
  1119.  
  1120.           \alt        The ALT modifier key. Used to describe shortcut-key
  1121.                       codes for styles.
  1122.  
  1123.           \shift      The SHIFT modifier key. Used to describe shortcut-key
  1124.                       codes for styles.
  1125.  
  1126.           \ctrl       The CTRL modifier key. Used to describe shortcut-key
  1127.                       codes for styles.
  1128.  
  1129.  
  1130.  
  1131.  
  1132.  
  1133.  
  1134.                          Microsoft Product Support Services
  1135.  
  1136.  
  1137.                                                                      Page 20
  1138.  
  1139.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  1140.  
  1141.           Control wordMeaning
  1142.           ------------------------------------------------------------------
  1143.           \fnN        Specifies a function key where N is the function key
  1144.                       number. Used to describe shortcut-key codes for styles
  1145.  
  1146.        The following is an example of an RTF style sheet
  1147.  
  1148.           {\stylesheet{\fs20 \sbasedon222\snext0{\*\keycode \shift\ctrl n}
  1149.           Normal;}{\s1\qr \fs20 \sbasedon0\snext1 FLUSHRIGHT;}{\s2\fi-
  1150.           720\li720\fs20\ri2880\sbasedon0\snext2 IND;}}
  1151.  
  1152.  
  1153.  
  1154.        and RTF paragraphs to which the styles are applied:
  1155.  
  1156.           \widowctrl\ftnbj\ftnrestart \sectd \linex0\endnhere \pard\plain
  1157.           \fs20 This is Normal style.
  1158.           \par \pard\plain \s1\qr\fs20
  1159.           This is right justified. I call this style FLUSHRIGHT.
  1160.           \par \pard\plain \s2\fi-720\li720\fs20\ri2880
  1161.           This is an indented paragraph. I call this style IND. It produces
  1162.           a hanging indent.
  1163.           \par}
  1164.  
  1165.  
  1166.  
  1167.        Some of the control words in this example are discussed in later
  1168.        sections. In the example, note that the properties of the style were
  1169.        emitted following the application of the style. This was done for two
  1170.        reasons: 1) to allow RTF readers that don't support styles to still
  1171.        retain all formatting, and 2) to allow the additive model for styles,
  1172.        where additional property changes are ``added'' on top of the defined
  1173.        style. Some RTF readers may not ``apply'' a style upon only
  1174.        encountering the style number without the accompanying formatting
  1175.        information because of this.
  1176.  
  1177.        Revision Marks
  1178.  
  1179.        This table allows tracking of multiple authors and reviewers of a
  1180.        document, and is used in conjunction with the character properties for
  1181.        revision marks.
  1182.  
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.  
  1193.  
  1194.  
  1195.  
  1196.  
  1197.                          Microsoft Product Support Services
  1198.  
  1199.  
  1200.                                                                      Page 21
  1201.  
  1202.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  1203.  
  1204.           Control word Definition
  1205.           ------------ -----------------------------------------------------
  1206.           \revtbl      This group consists of subgroups that each identify
  1207.                        the author of a revision in the document, as in
  1208.                        {Author1;}. This is a destination control word.
  1209.  
  1210.                        Revision conflicts, such as one author deleting
  1211.                        another's additions, are stored as one group, in the
  1212.                        following form:
  1213.  
  1214.                        CurrentAuthor\'00\'<length of previous author's
  1215.                        name>PreviousAuthor\'00
  1216.                        PreviousRevisionTime
  1217.  
  1218.                        The 4 bytes of the Date/Time (DTTM) structure are
  1219.                        emitted as ASCII characters, so values greater than
  1220.                        127 should be emitted as quoted hexadecimal values.
  1221.  
  1222.        All time references for revision marks use the following bit field
  1223.        structure, DTTM.
  1224.  
  1225.           Bit numbers Information   Range
  1226.           ----------- ------------- ----------------------------------------
  1227.           0-5         Minute        0-59
  1228.  
  1229.           6-10        Hour          0-23
  1230.  
  1231.           11-15       Day of month  1-31
  1232.  
  1233.           16-19       Month         1-12
  1234.  
  1235.           20-28       Year          = Year - 1900
  1236.  
  1237.           29-31       Day of week   0 (Sun)-6 (Sat)
  1238.  
  1239.        Document Area
  1240.  
  1241.        Once the RTF header is defined, the RTF reader has enough information
  1242.        to correctly read the actual document text. The document area has the
  1243.        following syntax.
  1244.  
  1245.           <document>  <info>? <docfmt>* <section>+
  1246.  
  1247.        Information Group
  1248.  
  1249.        The \info control word introduces the information group, which
  1250.        contains information about the document. This can include the title,
  1251.        author, keywords, comments, and other information specific to the
  1252.        file. This information is for use by a document-management utility, if
  1253.        available.
  1254.  
  1255.  
  1256.  
  1257.  
  1258.  
  1259.  
  1260.                          Microsoft Product Support Services
  1261.  
  1262.  
  1263.                                                                      Page 22
  1264.  
  1265.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  1266.  
  1267.        This group has the following syntax.
  1268.  
  1269.           <info>      '{' <title>? & <subject>? & <author>? & <operator>? &
  1270.                       <keywords>? & <comment>? & \version? & <doccomm>? &
  1271.                       \vern? & <creatim>? & <revtim>? & <printim>? &
  1272.                       <buptim>? & \edmins? & \nofpages? & \nofwords?
  1273.                       \nofchars? & \id? '}'
  1274.  
  1275.           <title>     '{' \title #PCDATA '}'
  1276.  
  1277.           <subject>   '{' \subject #PCDATA '}'
  1278.  
  1279.           <author>    '{' \author #PCDATA '}'
  1280.  
  1281.           <operator>  '{' \operator #PCDATA '}'
  1282.  
  1283.           <keywords>  '{' \keywords #PCDATA '}'
  1284.  
  1285.           <comment>   '{' \comment #PCDATA '}'
  1286.  
  1287.           <doccomm>   '{' \doccomm #PCDATA '}'
  1288.  
  1289.           <creatim>   '{' \creatim <time> '}'
  1290.  
  1291.           <revtim>    '{' \revtim <time> '}'
  1292.  
  1293.           <printim>   '{' \printim <time> '}'
  1294.  
  1295.           <buptim>    '{' \buptim <time> '}'
  1296.  
  1297.           <time>      \yr? \mo? \dy? \hr? \min? \sec?
  1298.  
  1299.        Some applications, such as Word, ask the user to type this information
  1300.        when saving the document in its native format. If the document is then
  1301.        saved as an RTF file or translated into RTF, the RTF writer specifies
  1302.        this information using the following control words. These control
  1303.        words are destinations and both the control words and the text should
  1304.        be enclosed in braces ({ }).
  1305.  
  1306.           Control word Meaning
  1307.           ------------ -----------------------------------------------------
  1308.           \title       Title of the document. This is a destination control
  1309.                        word.
  1310.  
  1311.           \subject     Subject of the document. This is a destination control
  1312.                        word.
  1313.  
  1314.           \author      Author of the document. This is a destination control
  1315.                        word.
  1316.  
  1317.           \operator    Person who last made changes to the document. This is
  1318.                        a destination control word.
  1319.  
  1320.  
  1321.  
  1322.  
  1323.                          Microsoft Product Support Services
  1324.  
  1325.  
  1326.                                                                      Page 23
  1327.  
  1328.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  1329.  
  1330.           Control word Meaning
  1331.           ------------ -----------------------------------------------------
  1332.           \keywords    Selected keywords for the document. This is a
  1333.                        destination control word.
  1334.  
  1335.           \comment     Comments; text is ignored. This is a destination
  1336.                        control word.
  1337.  
  1338.           \versionN    Version number of the document.
  1339.  
  1340.           \doccomm     Comments displayed in Word's Edit Summary Info dialog
  1341.                        box. This is a destination control word.
  1342.  
  1343.        The RTF writer may automatically enter other control words, including
  1344.        the following.
  1345.  
  1346.           Control word Meaning
  1347.           ------------ -----------------------------------------------------
  1348.           \vernN       Internal version number
  1349.  
  1350.           \creatim     Creation time
  1351.  
  1352.           \revtim      Revision time
  1353.  
  1354.           \printim     Last print time
  1355.  
  1356.           \buptim      Backup time
  1357.  
  1358.           \edminsN     Total editing time (in minutes)
  1359.  
  1360.           \yrN         Year
  1361.  
  1362.           \moN         Month
  1363.  
  1364.           \dyN         Day
  1365.  
  1366.           \hrN         Hour
  1367.  
  1368.           \minN        Minute
  1369.  
  1370.           \secN        Seconds
  1371.  
  1372.           \nofpagesN   Number of pages
  1373.  
  1374.           \nofwordsN   Number of words
  1375.  
  1376.           \nofcharsN   Number of characters
  1377.  
  1378.           \idN         Internal ID number
  1379.  
  1380.        Any control word described in the previous table that does not have a
  1381.        numeric parameter specifies a date; all dates are specified with the
  1382.  
  1383.  
  1384.  
  1385.  
  1386.                          Microsoft Product Support Services
  1387.  
  1388.  
  1389.                                                                      Page 24
  1390.  
  1391.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  1392.  
  1393.        \yr \mo \dy \hr \min \sec controls.
  1394.  
  1395.        An example of an information group follows:
  1396.  
  1397.           {\info{\title The Panda's Thumb}{\author Stephen J Gould}{\keywords
  1398.  
  1399.           science natural history }}
  1400.  
  1401.  
  1402.  
  1403.        Document Formatting Properties
  1404.  
  1405.        After the information group (if any), there may be some document
  1406.        formatting control words (described as <docfmt> in the document area
  1407.        syntax description). These control words specify the attributes of the
  1408.        document, such as margins and footnote placement. These attributes
  1409.        must precede the first plain-text character in the document.
  1410.  
  1411.        The control words that specify document formatting are listed in the
  1412.        following table (measurements are in twips; a twip is one-twentieth of
  1413.        a point). For omitted control words, RTF uses the default values.
  1414.  
  1415.           Control word   Meaning
  1416.           -------------- --------------------------------------------------
  1417.           \deftabN       Default tab width in twips (the default is 720).
  1418.  
  1419.           \hyphhotzN     Hyphenation hot zone in twips (the amount of space
  1420.                          at the right margin in which words are hyphenated).
  1421.  
  1422.           \hyphconsecN   N is the maximum number of consecutive lines that
  1423.                          will be allowed to end in a hyphen. 0 means no
  1424.                          limit.
  1425.  
  1426.           \hyphcaps      Toggles hyphenation of capitalized words (the
  1427.                          default is on). Append 1 or leave control word by
  1428.                          itself to toggle property on; append 0 (zero) to
  1429.                          turn it off.
  1430.  
  1431.           \hyphauto      Toggles automatic hyphenation (the default is off).
  1432.                          Append 1 or leave control word by itself to toggle
  1433.                          property on; append 0 (zero) to turn it off.
  1434.  
  1435.           \linestartN    Beginning line number (the default is 1).
  1436.  
  1437.           \fracwidth     Uses fractional character widths when printing
  1438.                          (QuickDraw [TM] only).
  1439.  
  1440.           \*\nextfile    Destination; the argument is the name of the file
  1441.                          to print or index next; it must be enclosed in
  1442.                          braces. This is a destination control word.
  1443.  
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.                          Microsoft Product Support Services
  1450.  
  1451.  
  1452.                                                                      Page 25
  1453.  
  1454.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  1455.  
  1456.           Control word   Meaning
  1457.           -------------- --------------------------------------------------
  1458.           \*\template    Destination; the argument is the name of a related
  1459.                          template file; it must be enclosed in braces. This
  1460.                          is a destination control word.
  1461.  
  1462.           \makebackup    Backup copy is made automatically when the document
  1463.                          is saved.
  1464.  
  1465.           \defformat     Tells the RTF reader that the document should be
  1466.                          saved in RTF format.
  1467.  
  1468.           \psover        Prints PostScript(R) over the text.
  1469.  
  1470.           \doctemp       Document is a boilerplate document. For Word for
  1471.                          Windows, this is a template; for Word for the
  1472.                          Macintosh, this is a stationery file.
  1473.  
  1474.           \deflangN      Defines the default language used in the document
  1475.                          used with a \plain control word. See the section
  1476.                          "Character-Formatting Properties" on page 51 of
  1477.                          this Application Note for a list of possible values
  1478.                          for N.
  1479.  
  1480.           Footnotes and Endnotes
  1481.  
  1482.           \fetN          Footnote/endnote type. This indicates what type of
  1483.                          notes are present in the document.
  1484.  
  1485.                          0  Footnotes only or nothing at all (the default).
  1486.  
  1487.                          1  Endnotes only.
  1488.  
  1489.                          2  Footnotes and endnotes both.
  1490.  
  1491.                          For backward compatibility, if \fet1 is emitted,
  1492.                          \endnotes or \enddoc will be emitted along with
  1493.                          \aendnotes or \aenddoc. RTF readers that understand
  1494.                          \fet will need to ignore the footnote-positioning
  1495.                          control words, and use the endnote control words
  1496.                          instead.
  1497.  
  1498.           \ftnsep        Text argument separates footnotes from the
  1499.                          document. This is a destination control word.
  1500.  
  1501.           \ftnsepc       Text argument separates continued footnotes from
  1502.                          the document. This is a destination control word.
  1503.  
  1504.           \ftncn         Text argument is a notice for continued footnotes.
  1505.                          This is a destination control word.
  1506.  
  1507.  
  1508.  
  1509.  
  1510.  
  1511.  
  1512.                          Microsoft Product Support Services
  1513.  
  1514.  
  1515.                                                                      Page 26
  1516.  
  1517.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  1518.  
  1519.           Control word   Meaning
  1520.           -------------- --------------------------------------------------
  1521.           \aftnsep       Text argument separates endnotes from the document.
  1522.                          This is a destination control word.
  1523.  
  1524.           \aftnsepc      Text argument separates continued endnotes from the
  1525.                          document. This is a destination control word.
  1526.  
  1527.           \aftncn        Text argument is a notice for continued endnotes.
  1528.                          This is a destination control word.
  1529.  
  1530.           \endnotes      Footnotes at the end of the section (the default).
  1531.  
  1532.           \enddoc        Footnotes at the end of the document.
  1533.  
  1534.           \ftntj         Footnotes beneath text (top justified).
  1535.  
  1536.           \ftnbj         Footnotes at the bottom of the page (bottom
  1537.                          justified).
  1538.  
  1539.           \aendnotes     Endnotes at end of section (the default).
  1540.  
  1541.           \aenddoc       Endnotes at end of document.
  1542.  
  1543.           \aftnbj        Endnotes at bottom of page (bottom justified).
  1544.  
  1545.           \aftntj        Endnotes beneath text (top justified).
  1546.  
  1547.           \ftnstartN     Beginning footnote number (the default is 1).
  1548.  
  1549.           \aftnstartN    Beginning endnote number (the default is 1).
  1550.  
  1551.           \ftnrstpg      Restart footnote numbering each page.
  1552.  
  1553.           \ftnrestart    Footnote numbers restart at each section. Microsoft
  1554.                          Word for the Macintosh uses this control to restart
  1555.                          footnote numbering at each page.
  1556.  
  1557.           \ftnrstcont    Continuous footnote numbering (the default).
  1558.  
  1559.           \aftnrestart   Restart endnote numbering each section.
  1560.  
  1561.           \aftnrstcont   Continuous endnote numbering (the default).
  1562.  
  1563.           \ftnnar        Footnote numbering--Arabic numbering (1, 2, 3, /)
  1564.  
  1565.           \ftnnalc       Footnote numbering--Alphabetic lowercase (a, b, c,
  1566.                          /)
  1567.  
  1568.           \ftnnauc       Footnote numbering--Alphabetic uppercase (A, B, C,
  1569.                          /)
  1570.  
  1571.  
  1572.  
  1573.  
  1574.  
  1575.                          Microsoft Product Support Services
  1576.  
  1577.  
  1578.                                                                      Page 27
  1579.  
  1580.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  1581.  
  1582.           Control word   Meaning
  1583.           -------------- --------------------------------------------------
  1584.           \ftnnrlc       Footnote numbering--Roman lowercase (i, ii, iii, /)
  1585.  
  1586.           \ftnnruc       Footnote numbering--Roman uppercase (I, II, III, /)
  1587.  
  1588.           \ftnnchi       Footnote numbering--Chicago Manual of Style (*, _,
  1589.                          _, S)
  1590.  
  1591.           \aftnnar       Endnote numbering--Arabic numbering (1, 2, 3, /)
  1592.  
  1593.           \aftnnalc      Endnote numbering--Alphabetic lowercase (a, b, c,
  1594.                          /)
  1595.  
  1596.           \aftnnauc      Endnote numbering--Alphabetic uppercase (A, B, C,
  1597.                          /)
  1598.  
  1599.           \aftnnrlc      Endnote numbering--Roman lowercase (i, ii, iii, /)
  1600.  
  1601.           \aftnnruc      Endnote numbering--Roman uppercase (I, II, III, /)
  1602.  
  1603.           \aftnnchi      Endnote numbering--Chicago Manual of Style (*, _,
  1604.                          _, S)
  1605.  
  1606.           Page Information
  1607.  
  1608.           \paperwN       Paper width in twips (the default is 12,240).
  1609.  
  1610.           \paperhN       Paper height in twips (the default is 15,840).
  1611.  
  1612.           \pszN          Used to differentiate between paper sizes with
  1613.                          identical dimensions under Windows NT [TM]. Values
  1614.                          1-41 correspond to paper sizes defined in DRIVINI.H
  1615.                          in the Windows 3.1 SDK (DMPAPER_ values). Values
  1616.                          greater than or equal to 42 correspond to user-
  1617.                          defined forms under Windows NT.
  1618.  
  1619.           \marglN        Left margin in twips (the default is 1800).
  1620.  
  1621.           \margrN        Right margin in twips (the default is 1800).
  1622.  
  1623.           \margtN        Top margin in twips (the default is 1440).
  1624.  
  1625.           \margbN        Bottom margin in twips (the default is 1440).
  1626.  
  1627.           \facingp       Facing pages (activates odd/even headers and
  1628.                          gutters).
  1629.  
  1630.           \gutterN       Gutter width in twips (the default is 0).
  1631.  
  1632.           \margmirror    Switches margin definitions on left and right
  1633.                          pages. Used in conjunction with \facingp.
  1634.  
  1635.  
  1636.  
  1637.  
  1638.                          Microsoft Product Support Services
  1639.  
  1640.  
  1641.                                                                      Page 28
  1642.  
  1643.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  1644.  
  1645.           Control word   Meaning
  1646.           -------------- --------------------------------------------------
  1647.           \landscape     Landscape format.
  1648.  
  1649.           \pgnstartN     Beginning page number (the default is 1).
  1650.  
  1651.           \widowctrl     Enable widow and orphan control.
  1652.  
  1653.           Linked Styles
  1654.  
  1655.           \linkstyles    Update document styles automatically based on
  1656.                          template.
  1657.  
  1658.           Compatibility Options
  1659.  
  1660.           \notabind      Don't add automatic tab stop for hanging indent.
  1661.  
  1662.           \wraptrsp      Wrap trailing spaces onto the next line.
  1663.  
  1664.           \prcolbl       Print all colors as black.
  1665.  
  1666.           \noextrasprl   Don't add extra space to line height for showing
  1667.                          raised/lowered characters.
  1668.  
  1669.           \nocolbal      Don't balance columns.
  1670.  
  1671.           \cvmme         Treat old-style escaped quotation marks (\") as
  1672.                          current style ("") in mail merge data documents.
  1673.  
  1674.           \sprstsp       Suppress extra line spacing at top of page.
  1675.                          Basically, this means to ignore any line spacing
  1676.                          larger than Auto at the top of a page.
  1677.  
  1678.           \sprsspbf      Suppress space before paragraph property after hard
  1679.                          page or column break.
  1680.  
  1681.           \otblrul       Combine table borders as done in Word 5.x for the
  1682.                          Macintosh. Contradictory table border information
  1683.                          is resolved in favor of the first cell.
  1684.  
  1685.           \transmf       Metafiles are considered transparent; don't blank
  1686.                          the area behind metafiles.
  1687.  
  1688.           \swpbdr        If a paragraph has a left border (not a box) and
  1689.                          the Different Odd And Even or Mirror Margins check
  1690.                          box is selected, Word will print the border on the
  1691.                          right for odd-numbered pages.
  1692.  
  1693.           \brkfrm        Show hard (manual) page breaks and column breaks in
  1694.                          frames.
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701.                          Microsoft Product Support Services
  1702.  
  1703.  
  1704.                                                                      Page 29
  1705.  
  1706.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  1707.  
  1708.           Control word   Meaning
  1709.           -------------- --------------------------------------------------
  1710.           Forms
  1711.  
  1712.           \formprot      This document is protected for forms.
  1713.  
  1714.           \allprot       This document has no unprotected areas.
  1715.  
  1716.           \formshade     This document has form field shading on.
  1717.  
  1718.           \formdisp      This document currently has a forms drop down or
  1719.                          check box selected.
  1720.  
  1721.           \printdata     This document has print form data only on.
  1722.  
  1723.           Revision Marks
  1724.  
  1725.           \revprot       This document is protected for revisions. The user
  1726.                          can edit the document, but revision marking cannot
  1727.                          be disabled.
  1728.  
  1729.           \revisions     Turns on revision marking.
  1730.  
  1731.           \revpropN      Argument indicates how revised text will be
  1732.                          displayed: 0 for no properties shown; 1 for bold; 2
  1733.                          for italic; 3 for underline (the default); 4 for
  1734.                          double underline.
  1735.  
  1736.           \revbarN       Vertical lines mark altered text, based on the
  1737.                          argument: 0 for no marking; 1 for left margin; 2
  1738.                          for right margin; 3 for outside (the default: left
  1739.                          on left pages, right on right pages).
  1740.  
  1741.           Annotations
  1742.  
  1743.           \annotprot     This document is protected for annotations. The
  1744.                          user cannot edit the document but can insert
  1745.                          annotations.
  1746.  
  1747.           Bidirectional Controls
  1748.  
  1749.           \rtldoc        This document will be formatted to have Arabic-
  1750.                          style pagination.
  1751.  
  1752.           \ltrdoc        This document will have English-style pagination
  1753.                          (the default).
  1754.  
  1755.  
  1756.  
  1757.        Note that the three document-protection control words (\formprot,
  1758.        \revprot, and \annotprot) are mutually exclusive; only one of the
  1759.        three can apply to any given document. Also, there is currently no
  1760.        method for storing passwords in RTF, so any document that associates a
  1761.  
  1762.  
  1763.  
  1764.                          Microsoft Product Support Services
  1765.  
  1766.  
  1767.                                                                      Page 30
  1768.  
  1769.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  1770.  
  1771.        password with a protection level will lose the password protection in
  1772.        RTF.
  1773.  
  1774.        For more information about bidirectional controls, see ``Bidirectional
  1775.        Language Support'' on page 84 of this Application Note.
  1776.  
  1777.        Section Text
  1778.  
  1779.        Each section in the RTF file has the following syntax:
  1780.  
  1781.           <section>    <secfmt>* <hdrftr>? <para>+ ( \sect <section>)?
  1782.  
  1783.        Section Formatting Properties
  1784.  
  1785.        At the beginning of each section, there may be some section-formatting
  1786.        control words (described as <secfmt> in the section text syntax
  1787.        description). These control words specify section-formatting
  1788.        properties, which apply to the text following the control word, with
  1789.        the exception of the section-break control words (those beginning with
  1790.        \sbk). Section-break control words describe the break preceding the
  1791.        text. These control words can appear anywhere in the section, not just
  1792.        at the start.
  1793.  
  1794.        Note that if the \sectd control word is not present, the current
  1795.        section inherits all section properties defined in the previous
  1796.        section.
  1797.  
  1798.        The section-formatting control words are listed in the following
  1799.        table.
  1800.  
  1801.           Control word   Meaning
  1802.           -------------- --------------------------------------------------
  1803.           \sect          New section.
  1804.  
  1805.           \sectd         Reset to default section properties.
  1806.  
  1807.           \endnhere      Endnotes included in the section.
  1808.  
  1809.           \binfsxnN      N is the printer bin used for the first page of the
  1810.                          section. If this control is not defined then the
  1811.                          first page uses the same printer bin as defined by
  1812.                          the \binsxnN control.
  1813.  
  1814.           \binsxnN       N is the printer bin used for the pages of the
  1815.                          section.
  1816.  
  1817.           \dsN           Designates section style; if a section style is
  1818.                          specified, style properties must be specified with
  1819.                          the section.
  1820.  
  1821.  
  1822.  
  1823.  
  1824.  
  1825.  
  1826.  
  1827.                          Microsoft Product Support Services
  1828.  
  1829.  
  1830.                                                                      Page 31
  1831.  
  1832.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  1833.  
  1834.           Control word   Meaning
  1835.           -------------- --------------------------------------------------
  1836.           \pnseclvlN     Used for multilevel lists. This property sets the
  1837.                          default numbering style for each corresponding
  1838.                          \pnlvlN control word (bullets and numbering
  1839.                          property for paragraphs) within that section. This
  1840.                          is a destination control word.
  1841.  
  1842.           \sectunlocked  This section is unlocked for forms.
  1843.  
  1844.           Section Break
  1845.  
  1846.           \sbknone       No section break.
  1847.  
  1848.           \sbkcol        Section break starts a new column.
  1849.  
  1850.           \sbkpage       Section break starts a new page (the default).
  1851.  
  1852.           \sbkeven       Section break starts at an even page.
  1853.  
  1854.           \sbkodd        Section break starts at an odd page.
  1855.  
  1856.           Columns
  1857.  
  1858.           \colsN         Number of columns for "snaking" (the default is 1).
  1859.  
  1860.           \colsxN        Space between columns in twips (the default is
  1861.                          720).
  1862.  
  1863.           \colnoN        Column number to be formatted; used to specify
  1864.                          formatting for variable-width columns.
  1865.  
  1866.           \colsrN        Space to right of column in twips; used to specify
  1867.                          formatting for variable-width columns.
  1868.  
  1869.           \colwN         Width of column in twips; used to override the
  1870.                          default constant width setting for variable-width
  1871.                          columns.
  1872.  
  1873.           \linebetcol    Line between columns.
  1874.  
  1875.           Line Numbering
  1876.  
  1877.           \linemodN      Line-number modulus amount to increase each line
  1878.                          number (the default is 1).
  1879.  
  1880.           \linexN        Distance from the line number to the left text
  1881.                          margin in twips (the default is 360). The automatic
  1882.                          distance is 0.
  1883.  
  1884.           \linestartsN   Beginning line number (the default is 1).
  1885.  
  1886.  
  1887.  
  1888.  
  1889.  
  1890.                          Microsoft Product Support Services
  1891.  
  1892.  
  1893.                                                                      Page 32
  1894.  
  1895.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  1896.  
  1897.           Control word   Meaning
  1898.           -------------- --------------------------------------------------
  1899.           \linerestart   Line numbers restart at \linestarts value.
  1900.  
  1901.           \lineppage     Line numbers restart on each page.
  1902.  
  1903.           \linecont      Line numbers continue from the preceding section.
  1904.  
  1905.           Page Information
  1906.  
  1907.           \pgwsxnN       N is the page width in twips. A \sectd resets the
  1908.                          value to that specified by \paperwN in the document
  1909.                          properties.
  1910.  
  1911.           \pghsxnN       N is the page height in twips. A \sectd resets the
  1912.                          value to that specified by \paperhN in the document
  1913.                          properties.
  1914.  
  1915.           \marglsxnN     N is the left margin of the page in twips. A \sectd
  1916.                          resets the value to that specified by \marglN in
  1917.                          the document properties.
  1918.  
  1919.           \margrsxnN     N is the right margin of the page in twips. A
  1920.                          \sectd resets the value to that specified by
  1921.                          \margrN in the document properties.
  1922.  
  1923.           \margtsxnN     N is the top margin of the page in twips. A \sectd
  1924.                          resets the value to that specified by \margtN in
  1925.                          the document properties.
  1926.  
  1927.           \margbsxnN     N is the bottom margin of the page in twips. A
  1928.                          \sectd resets the value to that specified by
  1929.                          \margbN in the document properties.
  1930.  
  1931.           \guttersxnN    N is the width of the gutter margin for the section
  1932.                          in twips. A \sectd resets the value to that
  1933.                          specified by \gutterN from the document properties.
  1934.                          If Facing Pages is turned off, the gutter will be
  1935.                          added to the left margin of all pages. If Facing
  1936.                          Pages is turned on, the gutter will be added to the
  1937.                          left side of odd-numbered pages and the right side
  1938.                          of even-numbered pages.
  1939.  
  1940.           \lndscpsxn     Page orientation is in landscape format. To mix
  1941.                          portrait and landscape sections within a document,
  1942.                          the \landscape control should not be used so that
  1943.                          the default for a section is portrait, which may be
  1944.                          overridden by the \lndscpsxn control.
  1945.  
  1946.           \titlepg       First page has a special format.
  1947.  
  1948.  
  1949.  
  1950.  
  1951.  
  1952.  
  1953.                          Microsoft Product Support Services
  1954.  
  1955.  
  1956.                                                                      Page 33
  1957.  
  1958.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  1959.  
  1960.           Control word   Meaning
  1961.           -------------- --------------------------------------------------
  1962.           \headeryN      Header is N twips from the top of the page (the
  1963.                          default is 720).
  1964.  
  1965.           \footeryN      Footer is N twips from the bottom of the page (the
  1966.                          default is 720).
  1967.  
  1968.           Page Numbers
  1969.  
  1970.           \pgnstartsN    Beginning page number (the default is 1).
  1971.  
  1972.           \pgncont       Continuous page numbering (the default).
  1973.  
  1974.           \pgnrestart    Page numbers restart at \pgnstarts value.
  1975.  
  1976.           \pgnxN         Page number is N twips from the right margin (the
  1977.                          default is 720).
  1978.  
  1979.           \pgnyN         Page number is N twips from the top margin (the
  1980.                          default is 720).
  1981.  
  1982.           \pgndec        Page-number format is decimal.
  1983.  
  1984.           \pgnucrm       Page-number format is uppercase roman numeral.
  1985.  
  1986.           \pgnlcrm       Page-number format is lowercase roman numeral.
  1987.  
  1988.           \pgnucltr      Page-number format is uppercase letter.
  1989.  
  1990.           \pgnlcltr      Page-number format is lowercase letter.
  1991.  
  1992.           \pgnhnN        Indicates which heading level is used to prefix a
  1993.                          heading number to the page number. This control
  1994.                          word can only be used in conjunction with numbered
  1995.                          heading styles. 0 specifies to not show heading
  1996.                          level (the default). Values 1-9 correspond to
  1997.                          heading levels 1 through 9.
  1998.  
  1999.           \pgnhnsh       Hyphen separator character. This separator and the
  2000.                          successive ones appear between the heading level
  2001.                          number and the page number.
  2002.  
  2003.           \pgnhnsp       Period separator character.
  2004.  
  2005.           \pgnhnsc       Colon separator character.
  2006.  
  2007.           \pgnhnsm       Em-dash (--) separator character.
  2008.  
  2009.           \pgnhnsn       En-dash (-) separator character.
  2010.  
  2011.  
  2012.  
  2013.  
  2014.  
  2015.  
  2016.                          Microsoft Product Support Services
  2017.  
  2018.  
  2019.                                                                      Page 34
  2020.  
  2021.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  2022.  
  2023.           Control word   Meaning
  2024.           -------------- --------------------------------------------------
  2025.           Vertical Alignment
  2026.  
  2027.           \vertalt       Text is top-aligned (the default).
  2028.  
  2029.           \vertalb       Text is bottom-aligned.
  2030.  
  2031.           \vertalc       Text is centered vertically.
  2032.  
  2033.           \vertalj       Text is justified vertically.
  2034.  
  2035.           Bidirectional Controls
  2036.  
  2037.           \rtlsect       This section will snake (newspaper style) columns
  2038.                          from right to left.
  2039.  
  2040.           \ltrsect       This section will snake (newspaper style) columns
  2041.                          from left to right (the default).
  2042.  
  2043.        Headers and Footers
  2044.  
  2045.        Headers and footers are RTF destinations. Each section in the document
  2046.        can have its own set of headers and footers. If no headers or footers
  2047.        are defined for a given section, the headers and footers from the
  2048.        previous section (if any) are used. Headers and footers have the
  2049.        following syntax:
  2050.  
  2051.           <hdrftr>    '{' <hdrctl> <para>+ '}' <hdrftr>?
  2052.  
  2053.           <hdrctl>    \header | \footer | \headerl | \headerr | \headerf |
  2054.                       \footerl | \footerr | \footerf
  2055.  
  2056.        Note that each separate <hdrftr> group must have a distinct <hdrctl>
  2057.        introducing it.
  2058.  
  2059.           Control word Meaning
  2060.           ------------ -----------------------------------------------------
  2061.           \header      Header on all pages. This is a destination control
  2062.                        word.
  2063.  
  2064.           \footer      Footer on all pages. This is a destination control
  2065.                        word.
  2066.  
  2067.           \headerl     Header on left pages only. This is a destination
  2068.                        control word.
  2069.  
  2070.           \headerr     Header on right pages only. This is a destination
  2071.                        control word.
  2072.  
  2073.           \headerf     Header on first page only. This is a destination
  2074.                        control word.
  2075.  
  2076.  
  2077.  
  2078.  
  2079.                          Microsoft Product Support Services
  2080.  
  2081.  
  2082.                                                                      Page 35
  2083.  
  2084.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  2085.  
  2086.           Control word Meaning
  2087.           ------------ -----------------------------------------------------
  2088.           \footerl     Footer on left pages only. This is a destination
  2089.                        control word.
  2090.  
  2091.           \footerr     Footer on right pages only. This is a destination
  2092.                        control word.
  2093.  
  2094.           \footerf     Footer on first page only. This is a destination
  2095.                        control word.
  2096.  
  2097.        The \headerl, \headerr, \footerl, and \footerr control words are used
  2098.        in conjunction with the \facingp control word, and the \headerf and
  2099.        \footerf control words are used in conjunction with the \titlepg
  2100.        control word. Many RTF readers will not function correctly if the
  2101.        appropriate document properties are not set. In particular, if
  2102.        \facingp is not set, then only \header and \footer should be used; if
  2103.        \facingp is set, then only \headerl, \headerr, \footerl, and \footerr
  2104.        should be used. Combining both \facingp and \titlepg is allowed. You
  2105.        should not use \header to set the headers for both pages when \facingp
  2106.        is set. You can use \headerf if \titlepg is not set, but no header
  2107.        will appear. For more information, see "Document Formatting
  2108.        Properties" on page 24 and "Section Formatting Properties" on page 30
  2109.        of this Application Note.
  2110.  
  2111.        If the previous section had a first page header or footer and had
  2112.        \titlepg set, and the current section does not, then the previous
  2113.        section's first page header or footer is disabled. However, it is not
  2114.        destroyed; if subsequent sections have \titlepg set, then the first
  2115.        page header or footer is restored.
  2116.  
  2117.        Paragraph Text
  2118.  
  2119.        There are two kinds of paragraphs: plain and table. A table is a
  2120.        collection of paragraphs, and a table row is a continuous sequence of
  2121.        paragraphs partitioned into cells. The \intbl paragraph-formatting
  2122.        control word identifies the paragraph as part of a table. For more
  2123.        information, see "Table Definitions" on page 46 of this Application
  2124.        Note. This control is inherited between paragraphs that do not have
  2125.        paragraph properties reset with \pard.
  2126.  
  2127.           <para>      <textpar> | <row>
  2128.  
  2129.           <textpar>   <pn>? <brdrdef>? <parfmt>* <apoctl>* <tabdef>?
  2130.                       <shading>? (\subdocument | <char>+) ( \par <para>)?
  2131.  
  2132.           <row>       <tbldef> <cell>+ \row
  2133.  
  2134.           <cell>      <textpar>+ \cell
  2135.  
  2136.        Paragraph Formatting Properties
  2137.  
  2138.        These control words (described as <parfmt> in the paragraph-text
  2139.  
  2140.  
  2141.  
  2142.                          Microsoft Product Support Services
  2143.  
  2144.  
  2145.                                                                      Page 36
  2146.  
  2147.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  2148.  
  2149.        syntax description) specify generic paragraph formatting properties.
  2150.        These control words can appear anywhere in the body of the paragraph,
  2151.        not just at the beginning.
  2152.  
  2153.        Note that if the \pard control word is not present, the current
  2154.        paragraph inherits all paragraph properties defined in the previous
  2155.        paragraph.
  2156.  
  2157.        The paragraph-formatting control words are listed in the following
  2158.        table.
  2159.  
  2160.           Control word Meaning
  2161.           ------------ -----------------------------------------------------
  2162.           \par         New paragraph.
  2163.  
  2164.           \pard        Resets to default paragraph properties.
  2165.  
  2166.           \sN          Designates paragraph style; if a paragraph style is
  2167.                        specified, style properties must be specified with the
  2168.                        paragraph. N references an entry in the stylesheet.
  2169.  
  2170.           \hyphpar     Toggles automatic hyphenation for the paragraph.
  2171.                        Append 1 or nothing to toggle property on; append 0
  2172.                        (zero) to turn it off.
  2173.  
  2174.           \intbl       Paragraph is part of a table.
  2175.  
  2176.           \keep        Keep paragraph intact.
  2177.  
  2178.           \nowidctlpar No widow/orphan control. This is a paragraph-level
  2179.                        property and is used to override the document-level
  2180.                        \widowctrl.
  2181.  
  2182.           \keepn       Keep paragraph with the next paragraph.
  2183.  
  2184.           \levelN      N is the outline level of the paragraph.
  2185.  
  2186.           \noline      No line numbering.
  2187.  
  2188.           \pagebb      Break page before the paragraph.
  2189.  
  2190.           \sbys        Side-by-side paragraphs.
  2191.  
  2192.           Alignment
  2193.  
  2194.           \ql          Left-aligned (the default).
  2195.  
  2196.           \qr          Right-aligned.
  2197.  
  2198.           \qj          Justified.
  2199.  
  2200.           \qc          Centered.
  2201.  
  2202.  
  2203.  
  2204.  
  2205.                          Microsoft Product Support Services
  2206.  
  2207.  
  2208.                                                                      Page 37
  2209.  
  2210.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  2211.  
  2212.           Control word Meaning
  2213.           ------------ -----------------------------------------------------
  2214.           Indentation
  2215.  
  2216.           \fiN         First-line indent (the default is 0).
  2217.  
  2218.           \liN         Left indent (the default is 0).
  2219.  
  2220.           \riN         Right indent (the default is 0).
  2221.  
  2222.           Spacing
  2223.  
  2224.           \sbN         Space before (the default is 0).
  2225.  
  2226.           \saN         Space after (the default is 0).
  2227.  
  2228.           \slN         Space between lines: if this control word is missing
  2229.                        or if \sl1000 is used, the line spacing is
  2230.                        automatically determined by the tallest character in
  2231.                        the line; if N is a positive value, this size is used
  2232.                        only if it is taller than the tallest character
  2233.                        (otherwise the tallest character is used); if N is a
  2234.                        negative value, the absolute value of N is used, even
  2235.                        if it is shorter than the tallest character.
  2236.  
  2237.           \slmultN     Line spacing multiple; indicates that the current line
  2238.                        spacing is a multiple of "Single" line spacing. This
  2239.                        control word can follow only the \sl control word and
  2240.                        works in conjunction with it.
  2241.  
  2242.                        0  "At Least" or "Exactly" line spacing.
  2243.  
  2244.                        1  Multiple line spacing, relative to "Single."
  2245.  
  2246.           Subdocuments
  2247.  
  2248.           \subdocument This indicates that a subdocument in a master
  2249.           N            document/subdocument relationship should occur here. N
  2250.                        represents an index into the file table. This control
  2251.                        word must be the only item in a paragraph.
  2252.  
  2253.           Bidirectional Controls
  2254.  
  2255.           \rtlpar      Text in this paragraph will be displayed with right-
  2256.                        to-left precedence.
  2257.  
  2258.           \ltrpar      Text in this paragraph will be displayed with left-to-
  2259.                        right precedence (the default).
  2260.  
  2261.        Tabs
  2262.  
  2263.        Any paragraph may have its own set of tabs. Tabs must follow this
  2264.  
  2265.  
  2266.  
  2267.  
  2268.                          Microsoft Product Support Services
  2269.  
  2270.  
  2271.                                                                      Page 38
  2272.  
  2273.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  2274.  
  2275.        syntax:
  2276.  
  2277.           <tabdef>    (<tab> | <bartab>) +
  2278.  
  2279.           <tab>       <tabkind>? <tablead>? \tx
  2280.  
  2281.           <bartab>    <tablead>? \tb
  2282.  
  2283.           <tabkind>   \tqr | \tqc | \tqdec
  2284.  
  2285.           <tablead>   \tldot | \tlhyph | \tlul | \tlth | \tleq
  2286.  
  2287.  
  2288.  
  2289.           Control word Meaning
  2290.           ------------ -----------------------------------------------------
  2291.           \txN         Tab position in twips from the left margin.
  2292.  
  2293.           \tqr         Flush-right tab.
  2294.  
  2295.           \tqc         Centered tab.
  2296.  
  2297.           \tqdec       Decimal tab.
  2298.  
  2299.           \tbN         Bar tab position in twips from the left margin.
  2300.  
  2301.           \tldot       Leader dots.
  2302.  
  2303.           \tlhyph      Leader hyphens.
  2304.  
  2305.           \tlul        Leader underline.
  2306.  
  2307.           \tlth        Leader thick line.
  2308.  
  2309.           \tleq        Leader equal sign.
  2310.  
  2311.        Bullets and Numbering
  2312.  
  2313.        To provide compatibility with existing RTF readers, all applications
  2314.        that can automatically bullet or number paragraphs will also emit the
  2315.        generated text as plain text in the \pntext group. This will allow
  2316.        existing RTF readers to capture the plain text and safely ignore the
  2317.        autonumber instructions. This group precedes all bulleted or numbered
  2318.        paragraphs, and will contain all the text and formatting that would be
  2319.        auto-generated. It should precede the '{'\*\pn / '}' destination, and
  2320.        it is the responsibility of RTF readers that understand the '{'\*\pn /
  2321.        '}' destination to ignore the \pntext group.
  2322.  
  2323.           <pn>        <pnseclvl> | <pnpara>
  2324.  
  2325.           <pnseclvl>  '{\*' \pnseclvl <pndesc>'}'
  2326.  
  2327.  
  2328.  
  2329.  
  2330.  
  2331.                          Microsoft Product Support Services
  2332.  
  2333.  
  2334.                                                                      Page 39
  2335.  
  2336.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  2337.  
  2338.           <pnpara>    <pntext> <pnprops>
  2339.  
  2340.           <pntext>    '{' \pntext <char> '}'
  2341.  
  2342.           <pnprops>   '{\*' \pn <pnlevel> <pndesc>'}'
  2343.  
  2344.           <pnlevel>   \pnlvl | \pnlvlblt | \pnlvlbody | \pnlvlcont
  2345.  
  2346.           <pndesc>    <pnnstyle> & <pnchrfmt> & <pntxtb> & <pntxta> & <pnfmt
  2347.  
  2348.           <pnnstyle>  \pncard | \pndec | \pnucltr | \pnucrm | \pnlcltr |
  2349.                       \pnlcrm | \pnord | \pnordt
  2350.  
  2351.           <pnchrfmt>  \pnf? & \pnfs? & \pnb? & \pni? & \pncaps? & \pnscaps?
  2352.                       <pnul>? & \pnstrike? & \pncf?
  2353.  
  2354.           <pnul>      \pnul | \pnuld | \pnuldb | \pnulnone | \pnulw
  2355.  
  2356.           <pnfmt>     \pnnumonce? & \pnacross? & \pnindent? & \pnsp? &
  2357.                       \pnprev? & <pnjust>? & \pnstart? & \pnhang? &
  2358.                       \pnrestart?
  2359.  
  2360.           <pnjust>    \pnqc | \pnql | \pnqr
  2361.  
  2362.           <pntxtb>    '{' \pntxtb #PCDATA'}'
  2363.  
  2364.           <pntxta>    '{' \pntxta #PCDATA'}'
  2365.  
  2366.        Settings below marked with an asterisk can be turned off by appending
  2367.        0 (zero) to the control word.
  2368.  
  2369.           Control word Definition
  2370.           ------------ -----------------------------------------------------
  2371.           \pntext      This group precedes all numbered/bulleted paragraphs,
  2372.                        and contains all auto-generated text and formatting.
  2373.                        It should precede the '{\*'\pn / '}' destination, and
  2374.                        it is the responsibility of RTF readers that
  2375.                        understand the '{\*'\pn / '}' destination to ignore
  2376.                        this preceding group. This is a destination control
  2377.                        word.
  2378.  
  2379.           \pn          Turns on paragraph numbering. This is a destination
  2380.                        control word.
  2381.  
  2382.           \pnlvlN      Paragraph level, where N is a level from 1 to 9.
  2383.                        Default set by \pnseclvlN section formatting property.
  2384.  
  2385.           \pnlvlblt    Bulleted paragraph (corresponds to level 11). The
  2386.                        actual character used for the bullet is stored in the
  2387.                        \pntxtb group.
  2388.  
  2389.           \pnlvlbody   Simple paragraph numbering (corresponds to level 10).
  2390.  
  2391.  
  2392.  
  2393.  
  2394.                          Microsoft Product Support Services
  2395.  
  2396.  
  2397.                                                                      Page 40
  2398.  
  2399.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  2400.  
  2401.           Control word Definition
  2402.           ------------ -----------------------------------------------------
  2403.           \pnlvlcont   Continue numbering but do not display number (`skip
  2404.                        numbering').
  2405.  
  2406.           \pnnumonce   Number each cell only once in a table (the default is
  2407.                        to number each paragraph in a table).
  2408.  
  2409.           \pnacross    Number across rows (the default is to number down
  2410.                        columns).
  2411.  
  2412.           \pnhang      Paragraph uses a hanging indent.
  2413.  
  2414.           \pnrestart   Restart numbering after each section break. Note that
  2415.                        this control word is used only in conjunction with the
  2416.                        Heading Numbering feature (applying multilevel
  2417.                        numbering to Heading style definitions).
  2418.  
  2419.           \pncard      Cardinal numbering (One, Two, Three).
  2420.  
  2421.           \pndec       Decimal numbering (1, 2, 3).
  2422.  
  2423.           \pnucltr     Uppercase alphabetic numbering (A, B, C).
  2424.  
  2425.           \pnucrm      Uppercase roman numbering (I, II, III).
  2426.  
  2427.           \pnlcltr     Lowercase alphabetic numbering (a, b, c).
  2428.  
  2429.           \pnlcrm      Lowercase roman numbering. (i, ii, iii).
  2430.  
  2431.           \pnord       Ordinal numbering (1st, 2nd, 3rd).
  2432.  
  2433.           \pnordt      Ordinal text numbering (First, Second, Third).
  2434.  
  2435.           \pnb         Bold numbering.*
  2436.  
  2437.           \pni         Italic numbering.*
  2438.  
  2439.           \pncaps      All Caps numbering.*
  2440.  
  2441.           \pnscaps     Small Caps numbering.*
  2442.  
  2443.           \pnul        Continuous underline.*
  2444.  
  2445.           \pnuld       Dotted underline.
  2446.  
  2447.           \pnuldb      Double underline.
  2448.  
  2449.           \pnulnone    Turns off underlining.
  2450.  
  2451.           \pnulw       Word underline.
  2452.  
  2453.  
  2454.  
  2455.  
  2456.  
  2457.                          Microsoft Product Support Services
  2458.  
  2459.  
  2460.                                                                      Page 41
  2461.  
  2462.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  2463.  
  2464.           Control word Definition
  2465.           ------------ -----------------------------------------------------
  2466.           \pnstrike    Strikethrough numbering.*
  2467.  
  2468.           \pncfN       Foreground color--index into color table (the default
  2469.                        is 0).
  2470.  
  2471.           \pnfN        Font number.
  2472.  
  2473.           \pnfsN       Font size (in half-points).
  2474.  
  2475.           \pnindentN   Minimum distance from margin to body text.
  2476.  
  2477.           \pnspN       Distance from number text to body text.
  2478.  
  2479.           \pnprev      Used for multilevel lists. Include information from
  2480.                        previous level in this level; for example, 1, 1.1,
  2481.                        1.1.1, 1.1.1.1
  2482.  
  2483.           \pnqc        Centered numbering.
  2484.  
  2485.           \pnql        Left-justified numbering.
  2486.  
  2487.           \pnqr        Right-justified numbering.
  2488.  
  2489.           \pnstartN    Start At number.
  2490.  
  2491.           \pntxta      Text after. This group contains the text that succeeds
  2492.                        the number. This is a destination control word.
  2493.  
  2494.           \pntxtb      Text before. This group contains the text that
  2495.                        precedes the number. This is a destination control
  2496.                        word.
  2497.  
  2498.        Note that there is a limit of 32 characters total for the sum of text
  2499.        before and text after for simple numbering. Multilevel numbering has a
  2500.        limit of 64 characters total for the sum of all levels.
  2501.  
  2502.        Paragraph Borders
  2503.  
  2504.        Paragraph borders have the following syntax:
  2505.  
  2506.           <brdrdef>   (<brdrseg> <brdr> )+
  2507.  
  2508.           <brdrseg>   \brdrt | \brdrb | \brdrl | \brdrr | \brdrbtw | \brdrba
  2509.                       | \box
  2510.  
  2511.           <brdr>      <brdrk> \brdrw? \brsp? \brdrcf?
  2512.  
  2513.           <brdrk>     \brdrs | \brdrth | \brdrsh | \brdrdb | \brdrdot |
  2514.                       \brdrdash | \brdrhair
  2515.  
  2516.  
  2517.  
  2518.  
  2519.  
  2520.                          Microsoft Product Support Services
  2521.  
  2522.  
  2523.                                                                      Page 42
  2524.  
  2525.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  2526.  
  2527.  
  2528.  
  2529.           Control word Meaning
  2530.           ------------ -----------------------------------------------------
  2531.           \brdrt       Border top.
  2532.  
  2533.           \brdrb       Border bottom.
  2534.  
  2535.           \brdrl       Border left.
  2536.  
  2537.           \brdrr       Border right.
  2538.  
  2539.           \brdrbtw     Consecutive paragraphs with identical border
  2540.                        formatting are considered part of a single group with
  2541.                        the border information applying to the entire group.
  2542.                        To have borders around individual paragraphs within
  2543.                        the group, the \brdrbtw control must be specified for
  2544.                        that paragraph.
  2545.  
  2546.           \brdrbar     Border outside (right side of odd-numbered pages, left
  2547.                        side of even-numbered pages).
  2548.  
  2549.           \box         Border around the paragraph (box paragraph).
  2550.  
  2551.           \brdrs       Single-thickness border.
  2552.  
  2553.           \brdrth      Double-thickness border.
  2554.  
  2555.           \brdrsh      Shadowed border.
  2556.  
  2557.           \brdrdb      Double border.
  2558.  
  2559.           \brdrdot     Dotted border.
  2560.  
  2561.           \brdrdash    Dashed border.
  2562.  
  2563.           \brdrhair    Hairline border.
  2564.  
  2565.           \brdrwN      N is the width in twips of the pen used to draw the
  2566.                        paragraph border line.
  2567.  
  2568.           \brdrcfN     N is the color of the paragraph border; specified as
  2569.                        an index into the color table in the RTF header.
  2570.  
  2571.           \brspN       Space in twips between borders and the paragraph.
  2572.  
  2573.        Paragraph Shading
  2574.  
  2575.        Paragraph shading has the following syntax:
  2576.  
  2577.           <shading>   ( \shading | <pat>) \cfpat? \cbpat?
  2578.  
  2579.  
  2580.  
  2581.  
  2582.  
  2583.                          Microsoft Product Support Services
  2584.  
  2585.  
  2586.                                                                      Page 43
  2587.  
  2588.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  2589.  
  2590.           <pat>       \bghoriz | \bgvert | \bgfdiag | \bgbdiag | \bgcross |
  2591.                       \bgdcross | \bgdkhoriz | \bgdkvert | \bgdkfdiag |
  2592.                       \bgdkbdiag | \bgdkcross | \bgdkdcross
  2593.  
  2594.  
  2595.  
  2596.           Control word Meaning
  2597.           ------------ -----------------------------------------------------
  2598.           \shadingN    N is the shading of the paragraph in hundredths of a
  2599.                        percent.
  2600.  
  2601.           \bghoriz     Specifies a horizontal background pattern for the
  2602.                        paragraph.
  2603.  
  2604.           \bgvert      Specifies a vertical background pattern for the
  2605.                        paragraph.
  2606.  
  2607.           \bgfdiag     Specifies a forward diagonal background pattern for
  2608.                        the paragraph ( \\\\).
  2609.  
  2610.           \bgbdiag     Specifies a backward diagonal background pattern for
  2611.                        the paragraph (//// ).
  2612.  
  2613.           \bgcross     Specifies a cross background pattern for the
  2614.                        paragraph.
  2615.  
  2616.           \bgdcross    Specifies a diagonal cross background pattern for the
  2617.                        paragraph.
  2618.  
  2619.           \bgdkhoriz   Specifies a dark horizontal background pattern for the
  2620.                        paragraph.
  2621.  
  2622.           \bgdkvert    Specifies a dark vertical background pattern for the
  2623.                        paragraph.
  2624.  
  2625.           \bgdkfdiag   Specifies a dark forward diagonal background pattern
  2626.                        for the paragraph ( \\\\).
  2627.  
  2628.           \bgdkbdiag   Specifies a dark backward diagonal background pattern
  2629.                        for the paragraph (//// ).
  2630.  
  2631.           \bgdkcross   Specifies a dark cross background pattern for the
  2632.                        paragraph.
  2633.  
  2634.           \bgdkdcross  Specifies a dark diagonal cross background pattern for
  2635.                        the paragraph.
  2636.  
  2637.           \cfpatN      N is the line color of the background pattern,
  2638.                        specified as an index into the document's color table.
  2639.  
  2640.           \cbpatN      N is the background color of the background pattern,
  2641.                        specified as an index into the document's color table.
  2642.  
  2643.  
  2644.  
  2645.  
  2646.                          Microsoft Product Support Services
  2647.  
  2648.  
  2649.                                                                      Page 44
  2650.  
  2651.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  2652.  
  2653.        Positioned Objects and Frames
  2654.  
  2655.        The following paragraph-formatting control words specify the location
  2656.        of a paragraph on the page. Consecutive paragraphs with the same frame
  2657.        formatting are considered to be part of the same frame. For two framed
  2658.        paragraphs to appear at the same position on a page, they must be
  2659.        separated by a paragraph with different or no frame information.
  2660.  
  2661.        Note that if any paragraph in a table row has any of these control
  2662.        words specified, then all paragraphs in the table row must have the
  2663.        same control words specified, either by inheriting the properties from
  2664.        the previous paragraph or by respecifying the controls.
  2665.  
  2666.        Paragraph positioning has the following syntax:
  2667.  
  2668.           <apoctl>    <framesize> & <horzpos> & <vertpos> & <txtwrap> &
  2669.                       <dropcap>
  2670.  
  2671.           <framesize> \absw? & \absh?
  2672.  
  2673.           <horzpos>   <hframe> & <hdist>
  2674.  
  2675.           <vertpos>   <vframe> & <vdist>
  2676.  
  2677.           <txtwrap>   \nowrap? & \dxfrtext? & \dfrmtxtx? &\dfrmtxty?
  2678.  
  2679.           <dropcap>   \dropcapli? & \dropcapt?
  2680.  
  2681.           <hframe>    \phmrg? | \phpg? | \phcol?
  2682.  
  2683.           <hdist>     \posx? | \posnegx? | \posxc? | \posxi? | \posxo? |
  2684.                       \posxl? | \posxr?
  2685.  
  2686.           <vframe>    \pvmrg? | \pvpg? | \pvpara?
  2687.  
  2688.           <vdist>     \posy? | \posnegy? | \posyt? | \posyil? | \posyb? |
  2689.                       \posyc?
  2690.  
  2691.  
  2692.  
  2693.           Control word Meaning
  2694.           ------------ -----------------------------------------------------
  2695.           \abswN       N is the width of the frame in twips.
  2696.  
  2697.           \abshN       N is the height of the frame in twips. A positive
  2698.                        number indicates the minimum height of the frame and a
  2699.                        negative number indicates the exact height of the
  2700.                        frame. A value of zero indicates that the height of
  2701.                        the frame adjusts to the contents of the frame. This
  2702.                        is the default for frames where no height is given.
  2703.  
  2704.  
  2705.  
  2706.  
  2707.  
  2708.  
  2709.                          Microsoft Product Support Services
  2710.  
  2711.  
  2712.                                                                      Page 45
  2713.  
  2714.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  2715.  
  2716.           Control word Meaning
  2717.           ------------ -----------------------------------------------------
  2718.           Horizontal Position
  2719.  
  2720.           \phmrg       Use the margin as the horizontal reference frame.
  2721.  
  2722.           \phpg        Use the page as the horizontal reference frame.
  2723.  
  2724.           \phcol       Use the column as the horizontal reference frame. This
  2725.                        is the default if no horizontal reference frame is
  2726.                        given.
  2727.  
  2728.           \posxN       Positions the frame N twips from the left edge of the
  2729.                        reference frame.
  2730.  
  2731.           \posnegxN    Same as \posx but allows arbitrary negative values.
  2732.  
  2733.           \posxc       Centers the frame horizontally within the reference
  2734.                        frame.
  2735.  
  2736.           \posxi       Positions the paragraph horizontally inside the
  2737.                        reference frame.
  2738.  
  2739.           \posxo       Positions the paragraph horizontally outside the
  2740.                        reference frame.
  2741.  
  2742.           \posxr       Positions the paragraph to the right within the
  2743.                        reference frame.
  2744.  
  2745.           \posxl       Positions the paragraph to the left within the
  2746.                        reference frame. This is the default if no horizontal
  2747.                        positioning information is given.
  2748.  
  2749.           Vertical Position
  2750.  
  2751.           \pvmrg       Positions the reference frame vertically relative to
  2752.                        the margin. This is the default if no vertical frame
  2753.                        positioning information is given.
  2754.  
  2755.           \pvpg        Positions the reference frame vertically relative to
  2756.                        the page.
  2757.  
  2758.           \pvpara      Positions the reference frame vertically relative to
  2759.                        the top of the top left corner of the next unframed
  2760.                        paragraph in the RTF stream.
  2761.  
  2762.           \posyN       Positions the paragraph N twips from the top edge of
  2763.                        the reference frame.
  2764.  
  2765.           \posnegyN    Same as \posy but allows arbitrary negative values.
  2766.  
  2767.           \posyil      Positions the paragraph vertically to be in-line.
  2768.  
  2769.  
  2770.  
  2771.  
  2772.                          Microsoft Product Support Services
  2773.  
  2774.  
  2775.                                                                      Page 46
  2776.  
  2777.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  2778.  
  2779.           Control word Meaning
  2780.           ------------ -----------------------------------------------------
  2781.           \posyt       Positions the paragraph at the top of the reference
  2782.                        frame.
  2783.  
  2784.           \posyc       Centers the paragraph vertically within the reference
  2785.                        frame.
  2786.  
  2787.           \posyb       Positions the paragraph at the bottom of the reference
  2788.                        frame.
  2789.  
  2790.           Text Wrapping
  2791.  
  2792.           \nowrap      Prevents text from flowing around the positioned
  2793.                        object.
  2794.  
  2795.           \dxfrtextN   Distance in twips of a positioned paragraph from text
  2796.                        in the main text flow in all directions.
  2797.  
  2798.           \dfrmtxtxN   N is the horizontal distance in twips from text on
  2799.                        both sides of the frame.
  2800.  
  2801.           \dfrmtxtyN   N is the vertical distance in twips from text on both
  2802.                        sides of the frame.
  2803.  
  2804.           Drop Caps
  2805.  
  2806.           \dropcapliN  Number of lines drop cap is to occupy. The range is 1
  2807.                        through 10.
  2808.  
  2809.           \dropcaptN   Type of drop cap:
  2810.  
  2811.                        1  In-text drop cap
  2812.  
  2813.                        2  Margin drop cap
  2814.  
  2815.        The following is an example of absolute-positioned text in a document:
  2816.  
  2817.           \par \pard \pvpg\phpg\posxc\posyt\absw5040\dxfrtest173 First APO
  2818.           para
  2819.  
  2820.           \par \pard \phmrg\posxo\posyc\dxfrtext1152 Second APO para
  2821.  
  2822.        Table Definitions
  2823.  
  2824.        There is no RTF table group; instead, tables are specified as
  2825.        paragraph properties. A table is represented as a sequence of table
  2826.        rows. A table row is a continuous sequence of paragraphs partitioned
  2827.        into cells. The table row begins with the \trowd control word and ends
  2828.        with the \row control word. Every paragraph that is contained in a
  2829.        table row must have the \intbl control word specified or inherited
  2830.        from the previous paragraph. A cell may have more than one paragraph
  2831.        in it; the cell is terminated by a cell mark (the \cell control word),
  2832.  
  2833.  
  2834.  
  2835.                          Microsoft Product Support Services
  2836.  
  2837.  
  2838.                                                                      Page 47
  2839.  
  2840.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  2841.  
  2842.        and the row is terminated by a row mark (the \row control word). Table
  2843.        rows can also be positioned. In this case, every paragraph in a table
  2844.        row must have the same positioning controls (see the <apoctl> controls
  2845.        on page 44 of this Application Note). Table properties may be
  2846.        inherited from the previous row; therefore, a series of table rows may
  2847.        be introduced by a single <tbldef>.
  2848.  
  2849.        An RTF table row has the following syntax, as shown in the general
  2850.        paragraph-text syntax shown on page 35 of this Application Note.
  2851.  
  2852.           <row>       <tbldef> <cell>+ \row
  2853.  
  2854.           <cell>      <textpar>+ \cell
  2855.  
  2856.        A table definition has the following syntax:
  2857.  
  2858.           <tbldef>    \trowd \trgaph <rowjust>? & <rowwrite>? <rowtop>? &
  2859.                       <rowbot>? & <rowleft>? & <rowright>? & <rowhor>? &
  2860.                       <rowvert>? & \trleft? & \trrh? \trhdr? & \trkeep?
  2861.                       <celldef>+
  2862.  
  2863.           <rowjust>    \trql | \trqr | \trqc
  2864.  
  2865.           <rowwrite>  \ltrrow | \rtlrow
  2866.  
  2867.           <rowtop>    \trbrdrt <brdr>
  2868.  
  2869.           <rowbot>    \trbrdrl <brdr>
  2870.  
  2871.           <rowleft>   \trbrdrb <brdr>
  2872.  
  2873.           <rowright>  \trbrdrr <brdr>
  2874.  
  2875.           <rowhor>    \trbrdrh <brdr>
  2876.  
  2877.           <rowvert>   \trbrdrv <brdr>
  2878.  
  2879.           <celldef>   ( \clmgf? & \clmrg? <celltop>? & <cellleft>? &
  2880.                       <cellbot>? & <cellright>? & <cellshad>?) \cellx
  2881.  
  2882.           <celltop>   \clbrdrt <brdr>
  2883.  
  2884.           <cellleft>  \clbrdrl <brdr>
  2885.  
  2886.           <cellbot>   \clbrdrb <brdr>
  2887.  
  2888.           <cellright> \clbrdrr <brdr>
  2889.  
  2890.           <cellshad>  <cellpat>? \clcfpat? & \clcbpat? & \clshdng
  2891.  
  2892.  
  2893.  
  2894.  
  2895.  
  2896.  
  2897.  
  2898.                          Microsoft Product Support Services
  2899.  
  2900.  
  2901.                                                                      Page 48
  2902.  
  2903.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  2904.  
  2905.           <cellpat>   \clbghoriz | \clbgvert | \clbgfdiag | \clbgbdiag |
  2906.                       \clbgcross | \clbgdcross | \clbgdkhor | \clbgdkvert |
  2907.                       \clbgdkfdiag | \clbgdkbdiag | \clbgdkcross |
  2908.                       \clbgdkdcross
  2909.  
  2910.        Note for <tbldef> that the number of \cellxs must match the number of
  2911.        \cells in the \row.
  2912.  
  2913.        The following control words further define options for each row of the
  2914.        table.
  2915.  
  2916.           Control word Meaning
  2917.           ------------ -----------------------------------------------------
  2918.           \trowd       Sets table row defaults.
  2919.  
  2920.           \trgaphN     Half the space between the cells of a table row in
  2921.                        twips.
  2922.  
  2923.           \cellxN      Defines the right boundary of a table cell, including
  2924.                        its half of the space between cells.
  2925.  
  2926.           \clmgf       The first cell in a range of table cells to be merged.
  2927.  
  2928.           \clmrg       Contents of the table cell are merged with those of
  2929.                        the preceding cell.
  2930.  
  2931.           Row Formatting
  2932.  
  2933.           \trql        Left-justifies a table row with respect to its
  2934.                        containing column.
  2935.  
  2936.           \trqr        Right-justifies a table row with respect to its
  2937.                        containing column.
  2938.  
  2939.           \trqc        Centers a table row with respect to its containing
  2940.                        column.
  2941.  
  2942.           \trleftN     Position of the leftmost edge of the table with
  2943.                        respect to the left edge of its column.
  2944.  
  2945.           \trrhN       Height of a table row in twips; when 0 (zero), the
  2946.                        height is sufficient for all the text in the line;
  2947.                        when positive, the height is guaranteed to be at least
  2948.                        the specified height; when negative, the absolute
  2949.                        value of the height is used, regardless of the height
  2950.                        of the text in the line.
  2951.  
  2952.           \trhdr       Table row header; this row should appear at the top of
  2953.                        every page the current table appears on.
  2954.  
  2955.  
  2956.  
  2957.  
  2958.  
  2959.  
  2960.  
  2961.                          Microsoft Product Support Services
  2962.  
  2963.  
  2964.                                                                      Page 49
  2965.  
  2966.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  2967.  
  2968.           Control word Meaning
  2969.           ------------ -----------------------------------------------------
  2970.           \trkeep      Table row keep together; this row cannot be split by a
  2971.                        page break. This property is assumed off unless the
  2972.                        control word is present.
  2973.  
  2974.           Bidirectional Controls
  2975.  
  2976.           \rtlrow      Cells in this table row will have right-to-left
  2977.                        precedence.
  2978.  
  2979.           \ltrrow      Cells in this table row will have left-to-right
  2980.                        precedence (the default).
  2981.  
  2982.           Row Borders
  2983.  
  2984.           \trbrdrt     Table row border top.
  2985.  
  2986.           \trbrdrl     Table row border left.
  2987.  
  2988.           \trbrdrb     Table row border bottom.
  2989.  
  2990.           \trbrdrr     Table row border right.
  2991.  
  2992.           \trbrdrh     Table row border horizontal (inside).
  2993.  
  2994.           \trbrdrv     Table row border vertical (inside).
  2995.  
  2996.           Cell Borders
  2997.  
  2998.           \clbrdrb     Bottom table cell border.
  2999.  
  3000.           \clbrdrt     Top table cell border.
  3001.  
  3002.           \clbrdrl     Left table cell border.
  3003.  
  3004.           \clbrdrr     Right table cell border.
  3005.  
  3006.           Cell Shading and Background Pattern
  3007.  
  3008.           \clshdngN    N is the shading of a table cell in hundredths of a
  3009.                        percent. This control should be included in RTF along
  3010.                        with cell border information.
  3011.  
  3012.           \clbghoriz   Specifies a horizontal background pattern for the
  3013.                        cell.
  3014.  
  3015.           \clbgvert    Specifies a vertical background pattern for the cell.
  3016.  
  3017.           \clbgfdiag   Specifies a forward diagonal background pattern for
  3018.                        the cell ( \\\\).
  3019.  
  3020.  
  3021.  
  3022.  
  3023.  
  3024.                          Microsoft Product Support Services
  3025.  
  3026.  
  3027.                                                                      Page 50
  3028.  
  3029.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  3030.  
  3031.           Control word Meaning
  3032.           ------------ -----------------------------------------------------
  3033.           \clbgbdiag   Specifies a backward diagonal background pattern for
  3034.                        the cell (//// ).
  3035.  
  3036.           \clbgcross   Specifies a cross background pattern for the cell.
  3037.  
  3038.           \clbgdcross  Specifies a diagonal cross background pattern for the
  3039.                        cell.
  3040.  
  3041.           \clbgdkhor   Specifies a dark horizontal background pattern for the
  3042.                        cell.
  3043.  
  3044.           \clbgdkvert  Specifies a dark vertical background pattern for the
  3045.                        cell.
  3046.  
  3047.           \clbgdkfdiag Specifies a dark forward diagonal background pattern
  3048.                        for the cell ( \\\\).
  3049.  
  3050.           \clbgdkbdiag Specifies a dark backward diagonal background pattern
  3051.                        for the cell (//// ).
  3052.  
  3053.           \clbgdkcross Specifies a dark cross background pattern for the
  3054.                        cell.
  3055.  
  3056.           \clbgdkdcros Specifies a dark diagonal cross background pattern for
  3057.           s            the cell.
  3058.  
  3059.           \clcfpatN    N is the line color of the background pattern.
  3060.  
  3061.           \clcbpatN    N is the background color of the background pattern.
  3062.  
  3063.        The following is an example of table text:
  3064.  
  3065.           \par \trowd \trqc\trgaph108\trrh280\trleft36
  3066.  
  3067.           \clbrdrt\brdrth \clbrdrl\brdrth \clbrdrb\brdrdb
  3068.  
  3069.           \clbrdrr\brdrdb \cellx3636\clbrdrt\brdrth
  3070.  
  3071.           \clbrdrl\brdrdb \clbrdrb\brdrdb \clbrdrr\brdrdb
  3072.  
  3073.           \cellx7236\clbrdrt\brdrth \clbrdrl\brdrdb
  3074.  
  3075.           \clbrdrb\brdrdb \clbrdrr\brdrdb \cellx10836\pard \intbl
  3076.  
  3077.           \cell \pard \intbl \cell \pard \intbl \cell \pard \intbl \row
  3078.  
  3079.           \trowd \trqc\trgaph108\trrh280\trleft36 \clbrdrt\brdrdb
  3080.  
  3081.           \clbrdrl\brdrth \clbrdrb \brdrsh\brdrs \clbrdrr\brdrdb
  3082.  
  3083.  
  3084.  
  3085.  
  3086.  
  3087.                          Microsoft Product Support Services
  3088.  
  3089.  
  3090.                                                                      Page 51
  3091.  
  3092.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  3093.  
  3094.           \cellx3636\clbrdrt\brdrdb \clbrdr \brdrdb
  3095.  
  3096.           \clbrdrb\brdrsh\brdrs \clbrdrr\brdrdb
  3097.  
  3098.           \cellx7236\clbrdrt\brdrdb \clbrdr \brdrdb
  3099.  
  3100.           \clbrdrb\brdrsh\brdrs \clbrdrr\brdrdb \cellx10836\pard
  3101.  
  3102.           \intbl \cell \pard \intbl \cell \pard \intbl \cell \pard
  3103.  
  3104.           \intbl \row \pard
  3105.  
  3106.        Character Text
  3107.  
  3108.        Character text has the following syntax:
  3109.  
  3110.           <char>      <ptext> | <atext> | '{' <char> '}'
  3111.  
  3112.           <ptext>     (<chrfmt>* <data>+ )+
  3113.  
  3114.           <data>      #PCDATA | <spec> | <pict> | <obj> | <do> | <foot> |
  3115.                       <annot> | <field> | <idx> | <toc> | <book>
  3116.  
  3117.        Character Formatting Properties
  3118.  
  3119.        These control words (described as <chrfmt> in the syntax description)
  3120.        change character formatting properties. A control word preceding plain
  3121.        text turns on the specified attribute. Some control words (indicated
  3122.        in the following table by an asterisk following the description) can
  3123.        be turned off by the control word followed by 0 (zero). For example,
  3124.        \b turns on bold, while \b0 turns off bold.
  3125.  
  3126.        The character-formatting control words are listed in the following
  3127.        table.
  3128.  
  3129.           Control word Meaning
  3130.  
  3131.           ------------ -----------------------------------------------------
  3132.           \plain       Reset character formatting properties to a default
  3133.                        value defined by the application. The associated
  3134.                        character formatting properties (described in the
  3135.                        section "Associated Character Properties" on page 56
  3136.                        of this Application Note) are also reset.
  3137.  
  3138.           \b           Bold.*
  3139.  
  3140.           \caps        All capitals.*
  3141.  
  3142.           \deleted     Marks the text as deletion revision marked.*
  3143.  
  3144.           \dnN         Subscript position in half-points (the default is 6).
  3145.  
  3146.  
  3147.  
  3148.  
  3149.  
  3150.                          Microsoft Product Support Services
  3151.  
  3152.  
  3153.                                                                      Page 52
  3154.  
  3155.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  3156.  
  3157.           Control word Meaning
  3158.  
  3159.           ------------ -----------------------------------------------------
  3160.           \sub         Subscripts text and shrinks point size according to
  3161.                        font information.
  3162.  
  3163.           \nosupersub  Turns off superscripting or subscripting.
  3164.  
  3165.           \expndN      Expansion or compression of the space between
  3166.                        characters in quarter-points; a negative value
  3167.                        compresses (the default is 0).
  3168.  
  3169.           \expndtwN    Expansion or compression of the space between
  3170.                        characters in twips; a negative value compresses. For
  3171.                        backward compatibility, both \expndtw and \expnd
  3172.                        should be emitted.
  3173.  
  3174.           \kerningN    Point size (in half-points) above which to kern
  3175.                        character pairs. \kerning0 turns off kerning.
  3176.  
  3177.           \fN          Font number. N refers to an entry in the font table.
  3178.  
  3179.           \fsN         Font size in half-points (the default is 24).
  3180.  
  3181.           \i           Italic.*
  3182.  
  3183.           \outl        Outline.*
  3184.  
  3185.           \revised     Text has been added since revision marking was turned
  3186.                        on.
  3187.  
  3188.           \revauthN    Index into the revision table. The content of the Nth
  3189.                        group in the revision table is considered to be the
  3190.                        author of that revision.
  3191.  
  3192.           \revdttmN    Time of the revision. The 32-bit DTTM structure is
  3193.                        emitted as a long integer.
  3194.  
  3195.           \scaps       Small capitals.*
  3196.  
  3197.           \shad        Shadow.*
  3198.  
  3199.           \strike      Strikethrough.*
  3200.  
  3201.           \ul          Continuous underline. \ul0 turns off all underlining.
  3202.  
  3203.           \uld         Dotted underline.
  3204.  
  3205.           \uldb        Double underline.
  3206.  
  3207.           \ulnone      Stops all underlining.
  3208.  
  3209.  
  3210.  
  3211.  
  3212.  
  3213.                          Microsoft Product Support Services
  3214.  
  3215.  
  3216.                                                                      Page 53
  3217.  
  3218.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  3219.  
  3220.           Control word Meaning
  3221.  
  3222.           ------------ -----------------------------------------------------
  3223.           \ulw         Word underline.
  3224.  
  3225.           \upN         Superscript position in half-points (the default is
  3226.                        6).
  3227.  
  3228.           \super       Superscripts text and shrinks point size according to
  3229.                        font information.
  3230.  
  3231.           \v           Hidden text.*
  3232.  
  3233.           \cfN         Foreground color (the default is 0).
  3234.  
  3235.           \cbN         Background color (the default is 0).
  3236.  
  3237.           \rtlch       The character data following this control word will be
  3238.                        treated as a right-to-left run.
  3239.  
  3240.           \ltrch       The character data following this control word will be
  3241.                        treated as a left-to-right run (the default).
  3242.  
  3243.           \csN         Designates character style; if a character style is
  3244.                        specified, style properties must be specified with the
  3245.                        character run. N refers to an entry in the style
  3246.                        table.
  3247.  
  3248.           \cchsN       Indicates any characters not belonging to the default
  3249.                        document character set and tells which character set
  3250.                        they do belong to. Macintosh character sets are
  3251.                        represented by values greater than 255. The values for
  3252.                        N correspond to the values for the \fcharset control
  3253.                        word.
  3254.  
  3255.           \langN       Applies a language to a character. N is a number
  3256.                        corresponding to a language. The \plain control word
  3257.                        resets the language property to the language defined
  3258.                        by \deflangN in the document properties.
  3259.  
  3260.        The following table defines the standard languages used by Microsoft.
  3261.        This table was generated by the Unicode [TM] group for use with
  3262.        TrueType and Unicode.
  3263.  
  3264.           Language name     Language ID
  3265.  
  3266.           ----------------  ------------------------------------------------
  3267.  
  3268.           No language       0x0400
  3269.  
  3270.           Albanian          0x041c
  3271.  
  3272.  
  3273.  
  3274.  
  3275.  
  3276.                          Microsoft Product Support Services
  3277.  
  3278.  
  3279.                                                                      Page 54
  3280.  
  3281.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  3282.  
  3283.           Language name     Language ID
  3284.  
  3285.           ----------------  ------------------------------------------------
  3286.  
  3287.           Arabic            0x0401
  3288.  
  3289.           Bahasa            0x0421
  3290.  
  3291.           Belgian Dutch     0x0813
  3292.  
  3293.           Belgian French    0x080c
  3294.  
  3295.           Brazilian         0x0416
  3296.           Portuguese
  3297.  
  3298.           Bulgarian         0x0402
  3299.  
  3300.           Catalan           0x0403
  3301.  
  3302.           Croato-Serbian    0x041a
  3303.           (Latin)
  3304.  
  3305.           Czech             0x0405
  3306.  
  3307.           Danish            0x0406
  3308.  
  3309.           Dutch             0x0413
  3310.  
  3311.           English           0x0c09
  3312.           (Australian)
  3313.  
  3314.           English (U.K.)    0x0809
  3315.  
  3316.           English (U.S.)    0x0409
  3317.  
  3318.           Finnish           0x040b
  3319.  
  3320.           French            0x040c
  3321.  
  3322.           French (Canadian) 0x0c0c
  3323.  
  3324.           German            0x0407
  3325.  
  3326.           Greek             0x0408
  3327.  
  3328.           Hebrew            0x040d
  3329.  
  3330.           Hungarian         0x040e
  3331.  
  3332.           Icelandic         0x040f
  3333.  
  3334.           Italian           0x0410
  3335.  
  3336.  
  3337.  
  3338.  
  3339.                          Microsoft Product Support Services
  3340.  
  3341.  
  3342.                                                                      Page 55
  3343.  
  3344.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  3345.  
  3346.           Language name     Language ID
  3347.  
  3348.           ----------------  ------------------------------------------------
  3349.  
  3350.           Japanese          0x0411
  3351.  
  3352.           Korean            0x0412
  3353.  
  3354.           Norwegian         0x0414
  3355.           (Bokmal)
  3356.  
  3357.           Norwegian         0x0814
  3358.           (Nynorsk)
  3359.  
  3360.           Polish            0x0415
  3361.  
  3362.           Portuguese        0x0816
  3363.  
  3364.           Rhaeto-Romanic    0x0417
  3365.  
  3366.           Romanian          0x0418
  3367.  
  3368.           Russian           0x0419
  3369.  
  3370.           Serbo-Croatian    0x081a
  3371.           (Cyrillic)
  3372.  
  3373.           Simplified        0x0804
  3374.           Chinese
  3375.  
  3376.           Slovak            0x041b
  3377.  
  3378.           Spanish           0x040a
  3379.           (Castilian)
  3380.  
  3381.           Spanish (Mexican) 0x080a
  3382.  
  3383.           Swedish           0x041d
  3384.  
  3385.           Swiss French      0x100c
  3386.  
  3387.           Swiss German      0x0807
  3388.  
  3389.           Swiss Italian     0x0810
  3390.  
  3391.           Thai              0x041e
  3392.  
  3393.           Traditional       0x0404
  3394.           Chinese
  3395.  
  3396.           Turkish           0x041f
  3397.  
  3398.  
  3399.  
  3400.  
  3401.  
  3402.                          Microsoft Product Support Services
  3403.  
  3404.  
  3405.                                                                      Page 56
  3406.  
  3407.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  3408.  
  3409.           Language name     Language ID
  3410.  
  3411.           ----------------  ------------------------------------------------
  3412.  
  3413.           Urdu              0x0420
  3414.  
  3415.        To read negative \expnd values from Word for the Macintosh, an RTF
  3416.        reader should use only the low-order 6 bits of the value read. Word
  3417.        for the Macintosh does not emit negative values for \expnd. Instead,
  3418.        it treats values from 57 through 63 as -7 through -1, respectively
  3419.        (the low-order 6 bits of 57 through 63 are the same as -7 through -1).
  3420.  
  3421.        Associated Character Properties
  3422.  
  3423.        Bidirectional-aware text processors often need to associate a Latin
  3424.        (or other left-to-right) font with an Arabic or Hebrew (or other
  3425.        right-to-left) font. The association is needed to match commonly used
  3426.        pairs of fonts in name, size, and other attributes. While RTF defines
  3427.        a broad variety of associated character properties, any implementation
  3428.        may choose to not implement a particular associated character property
  3429.        and share the property between the Latin and Arabic fonts.
  3430.  
  3431.        Property association uses the following syntax:
  3432.  
  3433.           <atext>     <ltrrun> | <rtlrun>
  3434.  
  3435.           <ltrrun>    \rtlch \af & <aprops>* \ltrch <ptext>
  3436.  
  3437.           <rtlrun>    \ltrch \af & <aprops>* \rtlch <ptext>
  3438.  
  3439.        Here are some examples of property association:
  3440.  
  3441.           \ltrch\af2\ab\au\rtlch\u Sample Text
  3442.  
  3443.        This is a right-to-left run. Text will use the default bidirectional
  3444.        font, and will be underlined. The left-to-right font associated with
  3445.        this run is font 2 (in the font table) with bolding and underlining.
  3446.  
  3447.           \plain\rtlch\ltrch Sample Text
  3448.  
  3449.        This is a left-to-right run. The right-to-left font and the left-to-
  3450.        right font use the default font (specified by \deff).
  3451.  
  3452.           \rtlch\af5\ab\ai\ltrch\u Sample Text
  3453.  
  3454.        This is a left-to-right run. The right-to-left font is font 5, bold
  3455.        and italicized. The left-to-right font is the default font,
  3456.        underlined. If the reader does not support underlining in the
  3457.        associated font, both fonts will be underlined.
  3458.  
  3459.        The property association control words (described as <aprops> in the
  3460.        syntax description) are listed in the following table. Some control
  3461.        words (indicated in the following table by an asterisk following the
  3462.  
  3463.  
  3464.  
  3465.                          Microsoft Product Support Services
  3466.  
  3467.  
  3468.                                                                      Page 57
  3469.  
  3470.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  3471.  
  3472.        description) can be turned off by the control word followed by 0
  3473.        (zero).
  3474.  
  3475.           Control word Meaning
  3476.  
  3477.           ------------ -----------------------------------------------------
  3478.  
  3479.           \ab          Associated font is bold.*
  3480.  
  3481.           \acaps       Associated font is all capitals.*
  3482.  
  3483.           \acfN        Associated foreground color (the default is 0).
  3484.  
  3485.           \adnN        Associated font is subscript position in half-points
  3486.                        (the default is 6).
  3487.  
  3488.           \aexpndN     Expansion or compression of the space between
  3489.                        characters in quarter-points; a negative value
  3490.                        compresses (the default is 0).
  3491.  
  3492.           \afN         Associated font number (the default is 0).
  3493.  
  3494.           \afsN        Associated font size in half-points (the default is
  3495.                        24).
  3496.  
  3497.           \ai          Associated font is italic.*
  3498.  
  3499.           \alangN      Language ID for the associated font. (This uses the
  3500.                        same language ID codes describedon page 53 of this
  3501.                        Application Note.)
  3502.  
  3503.           \aoutl       Associated font is outline.*
  3504.  
  3505.           \ascaps      Associated font is small capitals.*
  3506.  
  3507.           \ashad       Associated font is shadow.*
  3508.  
  3509.           \astrike     Associated font is strikethrough.*
  3510.  
  3511.           \aul         Associated font is continuous underline. \aul0 turns
  3512.                        off all underlining for the alternate font.
  3513.  
  3514.           \auld        Associated font is dotted underline.
  3515.  
  3516.           \auldb       Associated font is double underline.
  3517.  
  3518.           \aulnone     Associated font is no longer underlined.
  3519.  
  3520.           \aulw        Associated font is word underline.
  3521.  
  3522.           \aupN        Superscript position in half-points (the default is
  3523.                        6).
  3524.  
  3525.  
  3526.  
  3527.  
  3528.                          Microsoft Product Support Services
  3529.  
  3530.  
  3531.                                                                      Page 58
  3532.  
  3533.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  3534.  
  3535.        Special Characters
  3536.  
  3537.        The RTF Specification includes control words for special characters
  3538.        (described as <spec> in the character-text syntax description). If a
  3539.        special-character control word is not recognized by the RTF reader, it
  3540.        is ignored, and the text following it is considered plain text. The
  3541.        RTF Specification is flexible enough to allow new special characters
  3542.        to be added for interchange with other software.
  3543.  
  3544.        The special RTF characters are listed in the following table.
  3545.  
  3546.           Control word Meaning
  3547.           ------------ -----------------------------------------------------
  3548.           \chdate      Current date (as in headers).
  3549.  
  3550.           \chdpl       Current date in long format (for example, Thursday,
  3551.                        October 28, 1993).
  3552.  
  3553.           \chdpa       Current date in abbreviated format (for example, Thu,
  3554.                        Oct 28, 1993).
  3555.  
  3556.           \chtime      Current time (as in headers).
  3557.  
  3558.           \chpgn       Current page number (as in headers).
  3559.  
  3560.           \sectnum     Current section number (as in headers).
  3561.  
  3562.           \chftn       Automatic footnote reference (footnotes follow in a
  3563.                        group).
  3564.  
  3565.           \chatn       Annotation reference (annotation text follows in a
  3566.                        group).
  3567.  
  3568.           \chftnsep    Anchoring character for footnote separator.
  3569.  
  3570.           \chftnsepc   Anchoring character for footnote continuation.
  3571.  
  3572.           \cell        End of table cell.
  3573.  
  3574.           \row         End of table row.
  3575.  
  3576.           \par         End of paragraph.
  3577.  
  3578.           \sect        End of section and paragraph.
  3579.  
  3580.           \page        Required page break.
  3581.  
  3582.           \column      Required column break.
  3583.  
  3584.           \line        Required line break (no paragraph break).
  3585.  
  3586.  
  3587.  
  3588.  
  3589.  
  3590.  
  3591.                          Microsoft Product Support Services
  3592.  
  3593.  
  3594.                                                                      Page 59
  3595.  
  3596.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  3597.  
  3598.           Control word Meaning
  3599.           ------------ -----------------------------------------------------
  3600.           \softpage    Nonrequired page break. Emitted as it appears in
  3601.                        galley view.
  3602.  
  3603.           \softcol     Nonrequired column break. Emitted as it appears in
  3604.                        galley view.
  3605.  
  3606.           \softline    Nonrequired line break. Emitted as it appears in
  3607.                        galley view.
  3608.  
  3609.           \softlheight Nonrequired line height. This is emitted as a prefix
  3610.           N            to each line.
  3611.  
  3612.           \tab         Tab character; same as ASCII 9.
  3613.  
  3614.           \emdash      Em-dash (--).
  3615.  
  3616.           \endash      En-dash (-).
  3617.  
  3618.           \emspace     Nonbreaking space equal to width of character "m" in
  3619.                        current font.
  3620.  
  3621.           \enspace     Nonbreaking space equal to width of character "n" in
  3622.                        current font.
  3623.  
  3624.           \bullet      Bullet character.
  3625.  
  3626.           \lquote      Left single quotation mark.
  3627.  
  3628.           \rquote      Right single quotation mark.
  3629.  
  3630.           \ldblquote   Left double quotation mark.
  3631.  
  3632.           \rdblquote   Right double quotation mark.
  3633.  
  3634.           \|           Formula character.
  3635.  
  3636.           \~           Nonbreaking space.
  3637.  
  3638.           \-           Optional hyphen.
  3639.  
  3640.           \_           Nonbreaking hyphen.
  3641.  
  3642.           \:           Specifies a subentry in an index entry.
  3643.  
  3644.           \*           Marks a destination whose text should be ignored if
  3645.                        not understood by the RTF reader.
  3646.  
  3647.           \'hh         A hexadecimal value, based on the specified character
  3648.                        set (may be used to identify 8-bit values).
  3649.  
  3650.  
  3651.  
  3652.  
  3653.  
  3654.                          Microsoft Product Support Services
  3655.  
  3656.  
  3657.                                                                      Page 60
  3658.  
  3659.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  3660.  
  3661.           Control word Meaning
  3662.           ------------ -----------------------------------------------------
  3663.           \ltrmark     The following characters should be displayed from left
  3664.                        to right; usually found at the start of \ltrch runs.
  3665.  
  3666.           \rtlmark     The following characters should be displayed from
  3667.                        right to left; usually found at the start of \rtlch
  3668.                        runs.
  3669.  
  3670.           \zwj         Zero-width joiner. This is used to ligate (join)
  3671.                        characters.
  3672.  
  3673.           \zwnj        Zero-width nonjoiner. This is used for unligating a
  3674.                        characters.
  3675.  
  3676.        Note that an ASCII 9 is accepted as a tab character. A carriage return
  3677.        (character value 13) or linefeed (character value 10) will be treated
  3678.        as a \par control if the character is preceded by a backslash. You
  3679.        must include the backslash, or RTF ignores the control word. (You may
  3680.        also want to insert a carriage-return/linefeed pair without
  3681.        backslashes at least every 255 characters for better text transmission
  3682.        over communication lines.)
  3683.  
  3684.        The following are the code values for the special characters listed.
  3685.  
  3686.           Control word Word for Windows and OS/2  Apple Macintosh
  3687.           ------------ -------------------------- --------------------------
  3688.           \bullet      149                        0xA5
  3689.  
  3690.           \endash      150                        0xD1
  3691.  
  3692.           \emdash      151                        0xD0
  3693.  
  3694.           \lquote      145                        0xD4
  3695.  
  3696.           \rquote      146                        0xD5
  3697.  
  3698.           \ldblquote   147                        0xD2
  3699.  
  3700.           \rdblquote   148                        0xD3
  3701.  
  3702.        Bookmarks
  3703.  
  3704.        This destination may specify one of two control words: \*\bkmkstart,
  3705.        which indicates the start of the specified bookmark, and \*\bkmkend,
  3706.        which indicates the end of the specified bookmark.
  3707.  
  3708.        Bookmarks have the following syntax:
  3709.  
  3710.           <book>      <bookstart> | <bookend>
  3711.  
  3712.           <bookstart> '{\*' \bkmkstart ( \bkmkcolf? & \bkmkcoll?) #PCDATA '}
  3713.  
  3714.  
  3715.  
  3716.  
  3717.                          Microsoft Product Support Services
  3718.  
  3719.  
  3720.                                                                      Page 61
  3721.  
  3722.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  3723.  
  3724.           <bookend>   '{\*' \bkmkend #PCDATA '}'
  3725.  
  3726.        A bookmark is shown in the following example:
  3727.  
  3728.           \pard\plain \fs20 Kuhn believes that science, rather than
  3729.  
  3730.           discovering in experience certain structured
  3731.  
  3732.           relationships, actually creates (or already participates in)
  3733.  
  3734.           a presupposed structure to which it fits the data.
  3735.  
  3736.           {\bkmkstart paradigm} Kuhn calls such a presupposed
  3737.  
  3738.           structure a paradigm.{\bkmkend paradigm}
  3739.  
  3740.        The bookmark start and the bookmark end are matched with the bookmark
  3741.        tag. In the example, the bookmark tag was "paradigm." Each bookmark
  3742.        start should have a matching bookmark end; however, the bookmark start
  3743.        and the bookmark end may be in any order.
  3744.  
  3745.        \bkmkcolfN is used to denote the first column of a table covered by a
  3746.        bookmark. If it is not included, the first column is assumed.
  3747.        \bkmkcollN is used to denote the last column. If it is not used, the
  3748.        last column is assumed. These controls are used within the
  3749.        \*\bkmkstart destination following the \bkmkstart control. For
  3750.        example, {\*\bkmkstart\bkmkcolf2\bkmkcoll5 Table1} places the bookmark
  3751.        "Table1" on columns 2 through 5 of a table.
  3752.  
  3753.        Pictures
  3754.  
  3755.        An RTF file can include pictures created with other applications.
  3756.        These pictures can be in hexadecimal (the default) or binary format.
  3757.        Pictures are destinations, and begin with the \pict control word. A
  3758.        picture destination has the following syntax:
  3759.  
  3760.           <pict>       '{' \pict (<brdr>? & <shading>? & <picttype> &
  3761.                        <pictsize> & <metafileinfo>?) <data> '}'
  3762.  
  3763.           <picttype>   \macpict | \pmmetafile | \wmetafile | \dibitmap
  3764.                        <bitmapinfo> | \wbitmap <bitmapinfo>
  3765.  
  3766.           <bitmapinfo> \wbmbitspixel & \wbmplanes & \wbmwidthbytes
  3767.  
  3768.           <pictsize>   ( \picw & \pich) \picwgoal? & \pichgoal? \picscalex?
  3769.                        & \picscaley? & \picscaled? & \piccropt? & \piccropb?
  3770.                        & \piccropr? & \piccropl?
  3771.  
  3772.           <metafileinfo\picbmp & \picbpp
  3773.           >
  3774.  
  3775.           <data>       ( \bin #BDATA) | #SDATA
  3776.  
  3777.  
  3778.  
  3779.  
  3780.                          Microsoft Product Support Services
  3781.  
  3782.  
  3783.                                                                      Page 62
  3784.  
  3785.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  3786.  
  3787.        These control words are described in the following table (some
  3788.        measurements in this table are in twips; a twip is one-twentieth of a
  3789.        point).
  3790.  
  3791.           Control word   Meaning
  3792.           -------------- ---------------------------------------------------
  3793.           \macpict       Source of the picture is QuickDraw.
  3794.  
  3795.           \pmmetafileN   Source of the picture is an OS/2 metafile; the N
  3796.                          argument identifies the metafile type. The N values
  3797.                          are descibed on page 64 of this Application Note.
  3798.  
  3799.           \wmetafileN    Source of the picture is a Windows metafile; the N
  3800.                          argument identifies the metafile type (the default
  3801.                          is 1).
  3802.  
  3803.           \dibitmapN     Source of the picture is a Windows device-
  3804.                          independent bitmap; the N argument identifies the
  3805.                          bitmap type (must equal 0).
  3806.  
  3807.                          The information to be included in RTF from a
  3808.                          Windows device-independent bitmap is the
  3809.                          concatenation of the BITMAPINFO structure followed
  3810.                          by the actual pixel data.
  3811.  
  3812.           \wbitmapN      Source of the picture is a Windows device-dependent
  3813.                          bitmap; the N argument identifies the bitmap type
  3814.                          (must equal 0).
  3815.  
  3816.                          The information to be included in RTF from a
  3817.                          Windows device-dependent bitmap is the result of
  3818.                          the GetBitmapBits function.
  3819.  
  3820.        For more information on the GetDIBits and GetBitmapBits functions and
  3821.        the structure of Windows device-independent and device-dependent
  3822.        bitmaps, see Volume 1 and Volume 2 of the Programmer's Reference in
  3823.        the Microsoft Windows 3.1 Software Development Kit. For best device-
  3824.        independence and interoperability with Microsoft products, however,
  3825.        use of the \wbitmap and \dibitmap control words is discouraged.
  3826.        Rather, bitmaps should be embedded within Windows metafiles and the
  3827.        \wmetafile control word used. For more information on embedding
  3828.        bitmaps within metafiles, see Volume 1 and Volume 2 of the
  3829.        Programmer's Reference in the Microsoft Windows 3.1 Software
  3830.        Development Kit.
  3831.  
  3832.  
  3833.  
  3834.  
  3835.  
  3836.  
  3837.  
  3838.  
  3839.  
  3840.  
  3841.  
  3842.  
  3843.                          Microsoft Product Support Services
  3844.  
  3845.  
  3846.                                                                      Page 63
  3847.  
  3848.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  3849.  
  3850.           Control word      Meaning
  3851.           ----------------  ------------------------------------------------
  3852.           Bitmap Information
  3853.  
  3854.           \wbmbitspixelN    Number of adjacent color bits on each plane
  3855.                             needed to define a pixel (the default is 1).
  3856.                             Possible values are 1 (monochrome), 4 (16
  3857.                             colors), 8 (256 colors) and 24 (RGB).
  3858.  
  3859.           \wbmplanesN       Number of bitmap color planes (must equal 1).
  3860.  
  3861.           \wbmwidthbytesN   Specifies the number of bytes in each raster
  3862.                             line. This value must be an even number since the
  3863.                             Windows graphics device interface (GDI) assumes
  3864.                             that the bit values of a bitmap form an array of
  3865.                             integer (two-byte) values. In other words,
  3866.                             \wbmwidthbytes times 8 must be the next multiple
  3867.                             of 16 greater than or equal to the \picw (bitmap
  3868.                             width in pixels) value.
  3869.  
  3870.           Picture Size, Scaling, and Cropping
  3871.  
  3872.           \picwN            xExt field if the picture is a Windows metafile;
  3873.                             picture width in pixels if the picture is a
  3874.                             bitmap or from QuickDraw.
  3875.  
  3876.           \pichN            yExt field if the picture is a Windows metafile;
  3877.                             picture height in pixels if the picture is a
  3878.                             bitmap or from QuickDraw.
  3879.  
  3880.           \picwgoalN        Desired width of the picture in twips.
  3881.  
  3882.           \pichgoalN        Desired height of the picture in twips.
  3883.  
  3884.           \picscalexN       Horizontal scaling value; the N argument is a
  3885.                             value representing a percentage (the default is
  3886.                             100).
  3887.  
  3888.           \picscaleyN       Vertical scaling value; the N argument is a value
  3889.                             representing a percentage (the default is 100).
  3890.  
  3891.           \picscaled        Scales the picture to fit within the specified
  3892.                             frame; used only with \macpict pictures.
  3893.  
  3894.           \piccroptN        Top cropping value in twips; a positive value
  3895.                             crops toward the center of the picture; a
  3896.                             negative value crops away from the center, adding
  3897.                             a space border around picture (the default is 0).
  3898.  
  3899.  
  3900.  
  3901.  
  3902.  
  3903.  
  3904.  
  3905.  
  3906.                          Microsoft Product Support Services
  3907.  
  3908.  
  3909.                                                                      Page 64
  3910.  
  3911.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  3912.  
  3913.           Control word      Meaning
  3914.           ----------------  ------------------------------------------------
  3915.           \piccropbN        Bottom cropping value in twips; a positive value
  3916.                             crops toward the center of the picture; a
  3917.                             negative value crops away from the center, adding
  3918.                             a space border around picture (the default is 0).
  3919.  
  3920.           \piccroplN        Left cropping value in twips; a positive value
  3921.                             crops toward the center of the picture; a
  3922.                             negative value crops away from the center, adding
  3923.                             a space border around picture (the default is 0).
  3924.  
  3925.           \piccroprN        Right cropping value in twips; a positive value
  3926.                             crops toward the center of the picture; a
  3927.                             negative value crops away from the center, adding
  3928.                             a space border around picture (the default is 0).
  3929.  
  3930.           Metafile Information
  3931.  
  3932.           \picbmp           Specifies whether a metafile contains a bitmap.
  3933.  
  3934.           \picbppN          Specifies the bits per pixel in a metafile
  3935.                             bitmap. The valid range is 1-32, with 1, 4, 8,
  3936.                             and 24 being recognized.
  3937.  
  3938.           Picture Data
  3939.  
  3940.           \binN             The picture is in binary format; the numeric
  3941.                             parameter N is the number of bytes that follow.
  3942.                             Unlike all other controls, this control word
  3943.                             takes a 32-bit parameter.
  3944.  
  3945.        The \wbitmap control word is optional; if no other picture type is
  3946.        specified, the picture is assumed to be a Windows bitmap. If
  3947.        \wmetafile is specified, the N argument can be one of the following
  3948.        types.
  3949.  
  3950.           Type              N argument
  3951.           ----------------  ------------------------------------------------
  3952.           MM_TEXT           1
  3953.  
  3954.           MM_LOMETRIC       2
  3955.  
  3956.           MM_HIMETRIC       3
  3957.  
  3958.           MM_LOENGLISH      4
  3959.  
  3960.           MM_HIENGLISH      5
  3961.  
  3962.           MM_TWIPS          6
  3963.  
  3964.           MM_ISOTROPIC      7
  3965.  
  3966.  
  3967.  
  3968.  
  3969.                          Microsoft Product Support Services
  3970.  
  3971.  
  3972.                                                                      Page 65
  3973.  
  3974.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  3975.  
  3976.           Type              N argument
  3977.           ----------------  ------------------------------------------------
  3978.           MM_ANISOTROPIC    8
  3979.  
  3980.        For more information about these types, see volume 1 of the
  3981.        Programmer's Reference in the Microsoft Windows 3.1 Software
  3982.        Development Kit.
  3983.  
  3984.        If \pmmetafile is specified, the N argument can be one of the
  3985.        following types.
  3986.  
  3987.           Type              N argument
  3988.           ----------------  ------------------------------------------------
  3989.           PU_ARBITRARY      0x0004
  3990.  
  3991.           PU_PELS           0x0008
  3992.  
  3993.           PU_LOMETRIC       0x000C
  3994.  
  3995.           PU_HIMETRIC       0x0010
  3996.  
  3997.           PU_LOENGLISH      0x0014
  3998.  
  3999.           PU_HIENGLISH      0x0018
  4000.  
  4001.           PU_TWIPS          0x001C
  4002.  
  4003.        For more information about these types, see volume 2 of the OS/2
  4004.        Programmer's Reference.
  4005.  
  4006.        Be careful with spaces following control words when dealing with
  4007.        pictures in binary format. When reading files, RTF considers the first
  4008.        space after a control word the delimiter and subsequent spaces part of
  4009.        the document text. Therefore, any extra spaces are attached to the
  4010.        picture, with unpredictable results.
  4011.  
  4012.        RTF writers should not use the carriage-return/linefeed (CR/LF)
  4013.        combination to break up pictures in binary format. If they do, the
  4014.        CR/LF combination is treated as literal text and considered part of
  4015.        the picture data.
  4016.  
  4017.        The picture in hexadecimal or binary format follows the picture-
  4018.        destination control words. The following example illustrates the
  4019.        destination format:
  4020.  
  4021.           {\pict\wbitmap0\picw170\pich77\wbmbitspixel1\wbmplanes1\wbmwidthbyt
  4022.           es22
  4023.  
  4024.           \picwgoal505
  4025.  
  4026.           \pichgoal221
  4027.  
  4028.  
  4029.  
  4030.  
  4031.  
  4032.                          Microsoft Product Support Services
  4033.  
  4034.  
  4035.                                                                      Page 66
  4036.  
  4037.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  4038.  
  4039.           \picscalex172
  4040.  
  4041.           \picscaley172
  4042.  
  4043.           49f2000000000273023d1101a030
  4044.  
  4045.           3901000a000000000273023d98
  4046.  
  4047.           0048000200000275
  4048.  
  4049.           02040000200010275023e000000000
  4050.  
  4051.           273023d000002b90002b90002
  4052.  
  4053.           b90002b90002b9
  4054.  
  4055.           0002b90002b90002b90002b90002b90002
  4056.  
  4057.           b92222b90002b90002b90
  4058.  
  4059.           002b90002b9
  4060.  
  4061.           0002b90002b90002b90002b9000
  4062.  
  4063.        Objects
  4064.  
  4065.        Microsoft OLE links, Microsoft OLE embedded objects, and Macintosh
  4066.        Edition Manager subscriber objects are represented in RTF as objects.
  4067.        Objects are destinations that contain a data part and a result part.
  4068.        The data part is generally hidden to the application that produced the
  4069.        document. A separate application uses the data and supplies the
  4070.        appearance of the data. This appearance is the result part of the
  4071.        object.
  4072.  
  4073.        The representation of objects in RTF is designed to allow RTF readers
  4074.        that don't understand objects or don't use a particular type of object
  4075.        to use the current result in place of the object. This allows the
  4076.        appearance of the object to be maintained through the conversion even
  4077.        though the object functionality is lost. Each object comes with
  4078.        optional information about the object, a required destination that
  4079.        contains the object data, and an optional result that contains the
  4080.        current appearance of the object. This result contains standard RTF.
  4081.        It is an important responsibility of the RTF writer to provide the
  4082.        result so that existing RTF readers that either do not support objects
  4083.        or that do not support the particular type of object will be able to
  4084.        display the object.
  4085.  
  4086.        When the object is an OLE embedded or linked object, the data part of
  4087.        the object is the structure produced by the OLESaveToStream function.
  4088.        Some OLE clients rely on the OLE system to render the object and a
  4089.        copy of the result is not available to the RTF writer for that
  4090.        application. For these cases, the object result can be extracted from
  4091.        the structure produced by the OLESaveToStream function. For
  4092.  
  4093.  
  4094.  
  4095.                          Microsoft Product Support Services
  4096.  
  4097.  
  4098.                                                                      Page 67
  4099.  
  4100.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  4101.  
  4102.        information about the OLESaveToStream function, see the Microsoft
  4103.        Object Linking and Embedding Software Development Kit.
  4104.  
  4105.        The syntax for this destination is:
  4106.  
  4107.           <obj>       ( '{' \object (<objtype> & <objmod>? & <objclass>? &
  4108.                       <objname>? & <objtime>? & <objsize>? & <rsltmod>?)
  4109.                       <objdata> <result> '}' ) | <pubobject>
  4110.  
  4111.           <objtype>   \objemb | \objlink | \objautlink | \objsub | \objpub |
  4112.                       \objicemb
  4113.  
  4114.           <objmod>    \linkself? & \objlock? | \objupdate?
  4115.  
  4116.           <objclass>  '{\*' \objclass #PCDATA '}'
  4117.  
  4118.           <objname>   '{\*' \objname #PCDATA '}'
  4119.  
  4120.           <objtime>   '{\*' \objtime <time> '}'
  4121.  
  4122.           <rsltmod>   \rsltmerge? & <rslttype>?
  4123.  
  4124.           <rslttype>  \rsltrtf | \rslttxt | \rsltpict | \rsltbmp
  4125.  
  4126.           <objsize>   \objsetsize? & \objalign? & \objtransy? & <objhw>? &
  4127.                       \objcropt? & \objcropb? & \objcropl? & \objcropr? &
  4128.                       \objscalex? & \objscaley?
  4129.  
  4130.           <objhw>     \objh & \objw
  4131.  
  4132.           <objdata>   '{\*' \objdata (<objalias>? & <objsect>?) <data> '}'
  4133.  
  4134.           <objalias>  '{\*' \objalias <data> '}'
  4135.  
  4136.           <objsect>   '{\*' \objsect <data> '}'
  4137.  
  4138.           <result>    '{' \result <para>+ '}'
  4139.  
  4140.  
  4141.  
  4142.           Control word Meaning
  4143.  
  4144.           ------------ -----------------------------------------------------
  4145.  
  4146.           Object Type
  4147.  
  4148.           \objemb      An object type of OLE embedded object. If no type is
  4149.                        given for the object, the object is assumed to be of
  4150.                        type \objemb.
  4151.  
  4152.           \objlink     An object type of OLE link.
  4153.  
  4154.  
  4155.  
  4156.  
  4157.  
  4158.                          Microsoft Product Support Services
  4159.  
  4160.  
  4161.                                                                      Page 68
  4162.  
  4163.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  4164.  
  4165.           Control word Meaning
  4166.  
  4167.           ------------ -----------------------------------------------------
  4168.  
  4169.           \objautlink  An object type of OLE autolink.
  4170.  
  4171.           \objsub      An object type of Macintosh Edition Manager
  4172.                        subscriber.
  4173.  
  4174.           \objpub      An object type of Macintosh Edition Manager publisher.
  4175.  
  4176.           \objicemb    An object type of MS(R) Word for the Macintosh
  4177.                        Installable Command (IC) Embedder.
  4178.  
  4179.           Object Information
  4180.  
  4181.           \linkself    The object is a link to another part of the same
  4182.                        document.
  4183.  
  4184.           \objlock     Locks the object from any updates.
  4185.  
  4186.           \objupdate   Forces an update to the object before displaying it.
  4187.                        Note that this will override any values in the
  4188.                        <objsize> control words, but reasonable values should
  4189.                        always be provided for these to maintain backwards
  4190.                        compatibility.
  4191.  
  4192.           \objclass    The text argument is the object class to use for this
  4193.                        object; ignore the class specified in the object data.
  4194.                        This is a destination control word.
  4195.  
  4196.           \objname     The text argument is the name of this object. This is
  4197.                        a destination control word.
  4198.  
  4199.           \objtime     Describes the time that the object was last updated.
  4200.  
  4201.           Object Size, Position, Cropping, and Scaling
  4202.  
  4203.           \objhN       N is the original object height in twips, assuming the
  4204.                        object has a graphical representation.
  4205.  
  4206.           \objwN       N is the original object width in twips, assuming the
  4207.                        object has a graphical representation.
  4208.  
  4209.           \objsetsize  Forces the object server to set the object's
  4210.                        dimensions to that specified by the client.
  4211.  
  4212.           \objalignN   N is the distance in twips from the left edge of the
  4213.                        objects that should be aligned on a tab stop. This is
  4214.                        needed to place Equation Editor equations correctly in
  4215.                        line.
  4216.  
  4217.  
  4218.  
  4219.  
  4220.  
  4221.                          Microsoft Product Support Services
  4222.  
  4223.  
  4224.                                                                      Page 69
  4225.  
  4226.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  4227.  
  4228.           Control word Meaning
  4229.  
  4230.           ------------ -----------------------------------------------------
  4231.  
  4232.           \objtransyN  N is the distance in twips the objects should be moved
  4233.                        vertically with respect to the baseline. This is
  4234.                        needed to place Math Type equations correctly in line.
  4235.  
  4236.           \objcroptN   N is the top cropping distance in twips.
  4237.  
  4238.           \objcropbN   N is the bottom cropping distance in twips.
  4239.  
  4240.           \objcroplN   N is the left cropping distance in twips.
  4241.  
  4242.           \objcroprN   N is the right cropping distance in twips.
  4243.  
  4244.           \objscalexN  N is the horizontal scaling percentage.
  4245.  
  4246.           \objscaleyN  N is the vertical scaling percentage.
  4247.  
  4248.           Object Data
  4249.  
  4250.           \objdata     This subdestination contains the data for the object
  4251.                        in the appropriate format; OLE objects are in
  4252.                        OLESaveToStream format. This is a destination control
  4253.                        word.
  4254.  
  4255.           \objalias    This subdestination contains the Alias Record for the
  4256.                        publisher object for the Macintosh Edition Manager.
  4257.                        This is a destination control word.
  4258.  
  4259.           \objsect     This subdestination contains the Section Record for
  4260.                        the publisher object for the Macintosh Edition
  4261.                        Manager. This is a destination control word.
  4262.  
  4263.           Object Result
  4264.  
  4265.           \rsltrtf     Forces the result to be rich-text format, if possible.
  4266.  
  4267.           \rsltpict    Forces the result to be a Windows metafile or MacPict
  4268.                        image format, if possible.
  4269.  
  4270.           \rsltbmp     Forces the result to be a bitmap, if possible.
  4271.  
  4272.           \rslttxt     Forces the result to be plain text, if possible.
  4273.  
  4274.           \rsltmerge   Uses the formatting of the current result whenever a
  4275.                        new result is obtained.
  4276.  
  4277.  
  4278.  
  4279.  
  4280.  
  4281.  
  4282.  
  4283.  
  4284.                          Microsoft Product Support Services
  4285.  
  4286.  
  4287.                                                                      Page 70
  4288.  
  4289.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  4290.  
  4291.           Control word Meaning
  4292.  
  4293.           ------------ -----------------------------------------------------
  4294.  
  4295.           \result      The result destination is optional in the \object
  4296.                        destination. It contains the last update of the result
  4297.                        of the object. The data of the result destination
  4298.                        should be standard RTF so that RTF readers that don't
  4299.                        understand objects or the type of object represented
  4300.                        can use the current result in the object's place to
  4301.                        maintain appearance. This is a destination control
  4302.                        word.
  4303.  
  4304.        Macintosh Edition Manager Publisher Objects
  4305.  
  4306.        Word for the Macintosh writes publisher objects for the Macintosh
  4307.        Edition Manager in terms of bookmarks (see "Bookmarks" on page 60 of
  4308.        this Application Note). The range of publisher objects are marked as
  4309.        bookmarks, so these controls are all used within the \bkmkstart
  4310.        destination. The RTF syntax for a publisher object is:
  4311.  
  4312.           <pubobject>  '{\*' \bkmkstart \bkmkpub \pubauto? (<objalias>? &
  4313.                        <objsect>) #PCDATA '}'
  4314.  
  4315.           Control word Meaning
  4316.  
  4317.           ------------ -----------------------------------------------------
  4318.  
  4319.           \bkmkpub     The bookmark marks a Macintosh Edition Manager
  4320.                        publisher object.
  4321.  
  4322.           \pubauto     The publisher object updates all Macintosh Edition
  4323.                        Manager subscribers of this object automatically
  4324.                        whenever it is edited.
  4325.  
  4326.        Drawing Objects
  4327.  
  4328.        Drawing objects and the drawing primitives enumerated within drawing
  4329.        object groups use the syntax described by the following tables.
  4330.  
  4331.           <do>        '{\*' \do <dohead> <dpinfo>'}'
  4332.  
  4333.           <dohead>    <dobx> <doby> <dodhgt> <dolock>?
  4334.  
  4335.           <dobx>      \dobxpage | \dobxcolumn | \dobxmargin
  4336.  
  4337.           <doby>      \dobypage | \dobypara | \dobymargin
  4338.  
  4339.           <dodhgt>    \dodhgt
  4340.  
  4341.           <dolock>    \dolock
  4342.  
  4343.  
  4344.  
  4345.  
  4346.  
  4347.                          Microsoft Product Support Services
  4348.  
  4349.  
  4350.                                                                      Page 71
  4351.  
  4352.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  4353.  
  4354.           <dpinfo>     <dpgroup> | <dpcallout> | <dpsimple>
  4355.  
  4356.           <dpgroup>   \dpgroup \dpcount <dphead> <dpinfo>+ \dpendgroup
  4357.                       <dphead>
  4358.  
  4359.           <dpcallout> \dpcallout <cotype> <coangle>? <coaccent>?
  4360.                       <cosmartattach>? <cobestfit>? <cominusx>? <cominusy>?
  4361.                       <coborder>? <codescent>? \dpcooffset \dpcolength
  4362.                       <dphead> <dppolyline> <dphead> <dpprops> <dptextbox>
  4363.                       <dphead> <dpprops>
  4364.  
  4365.           <dpsimple>  <dpsimpledpk> <dphead> <dpprops>
  4366.  
  4367.           <dpsimpledp <dpline> | <dprect> | <dptextbox> | <dpellipse> |
  4368.           >           <dppolyline> | <dparc>
  4369.  
  4370.           <dpline>    \dpline <dppt> <dppt>
  4371.  
  4372.           <dprect>    \dprect (\dproundr)?
  4373.  
  4374.           <dptextbox> \dptxbx \dptxbxmar '{' \dptxbxtext <para>+'}'
  4375.  
  4376.           <dpellipse> \dpellipse
  4377.  
  4378.           <dparc>     \dparc \dparcflipx? \dparcflipy?
  4379.  
  4380.           <dppolyline \dppolyline (\dppolygon)? \dppolycount <dppt>+
  4381.  
  4382.           <dppt>      \dpptx \dppty
  4383.  
  4384.           <dphead>    \dpx \dpy \dpxsize \dpysize
  4385.  
  4386.        Note that in <dpgroup> the number of <dpinfo>s is equal to the
  4387.        argument of \dpcount, while in <dppolyline> the number of <dppt>s is
  4388.        equal to the argument of \dppolycount.
  4389.  
  4390.        The following elements of the drawing-object syntax pertain
  4391.        specifically to callout objects:
  4392.  
  4393.           <cotype>    \dpcotright | \dpcotsingle | \dpcotdouble |
  4394.                       \dpcottriple
  4395.  
  4396.           <coangle>   \dpcoa
  4397.  
  4398.           <coaccent>  \dpcoaccent
  4399.  
  4400.           <cosmartatt \dpcosmarta
  4401.           ch>
  4402.  
  4403.           <cobestfit> \dpcobestfit
  4404.  
  4405.           <cominusx>  \dpcominusx
  4406.  
  4407.  
  4408.  
  4409.  
  4410.                          Microsoft Product Support Services
  4411.  
  4412.  
  4413.                                                                      Page 72
  4414.  
  4415.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  4416.  
  4417.           <cominusy>  \dpcominusy
  4418.  
  4419.           <coborder>  \dpcoborder
  4420.  
  4421.           <codescent> \dpcodtop | \dpcodcenter | \dpcodbottom | \dpcodabs
  4422.  
  4423.        The remaining elements of the drawing object syntax are properties
  4424.        applied to individual drawn primitives:
  4425.  
  4426.           <dpprops>   <lineprops>? <fillprops>? <endstylestart>?
  4427.                       <endstyleend>? <shadow>?
  4428.  
  4429.           <lineprops> <linestyle> <linecolor> \dplinew
  4430.  
  4431.           <linestyle> \dplinesolid | \dplinehollow | \dplinedash | \dplinedo
  4432.                       | \dplinedado | \dplinedadodo
  4433.  
  4434.           <linecolor> <linegray> | <linergb>
  4435.  
  4436.           <linegray>  \dplinegray
  4437.  
  4438.           <linergb>   \dplinecor \dplinecog \dplinecob<linepal>?
  4439.  
  4440.           <linepal>   \dplinepal
  4441.  
  4442.           <fillprops> <fillcolorfg> <fillcolorbg> \dpfillpat
  4443.  
  4444.           <fillcolorf <fillfggray> | <fillfgrgb>
  4445.           >
  4446.  
  4447.           <fillfggray \dpfillfggray
  4448.  
  4449.           <fillfgrgb> \dpfillfgcr \dpfillfgcg \dpfillfgcb<fillfgpal>?
  4450.  
  4451.           <fillfgpal> \dpfillfgpal
  4452.  
  4453.           <fillcolorb <fillbggray> | <fillbgrgb>
  4454.           >
  4455.  
  4456.           <fillbggray \dpfillbggray
  4457.  
  4458.           <fillbgrgb> \dpfillbgcr \dpfillbgcg \dpfillbgcb<fillbgpal>?
  4459.  
  4460.           <fillbgpal> \dpfillbgpal
  4461.  
  4462.           <endstylest <arrowstartfill> \dpastartl \dpastartw
  4463.           rt>
  4464.  
  4465.           <arrowstart \dpastartsol | \dpastarthol
  4466.           ill>
  4467.  
  4468.  
  4469.  
  4470.  
  4471.  
  4472.  
  4473.                          Microsoft Product Support Services
  4474.  
  4475.  
  4476.                                                                      Page 73
  4477.  
  4478.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  4479.  
  4480.           <endstyleen <arrowendfill> \dpaendl \dpaendw
  4481.           >
  4482.  
  4483.           <arrowendfi \dpaendsol | \dpaendhol
  4484.           l>
  4485.  
  4486.           <shadow>    \dpshadow \dpshadx \dpshady
  4487.  
  4488.        The following table describes the control words for the drawing object
  4489.        group in detail. All color values are RGB values between 0-255. All
  4490.        distances are in twips. All other values are as indicated.
  4491.  
  4492.           Control word    Definition
  4493.           --------------- -------------------------------------------------
  4494.           \do             Indicates a drawing object is to be inserted at
  4495.                           this point in the character stream. This is a
  4496.                           destination control word.
  4497.  
  4498.           \dolock         The drawing object's anchor is locked and cannot
  4499.                           be moved.
  4500.  
  4501.           \dobxpage       The drawing object is page relative in the x-
  4502.                           direction.
  4503.  
  4504.           \dobxcolumn     The drawing object is column relative in the x-
  4505.                           direction.
  4506.  
  4507.           \dobxmargin     The drawing object is margin relative in the x-
  4508.                           direction.
  4509.  
  4510.           \dobypage       The drawing object is page relative in the y-
  4511.                           direction.
  4512.  
  4513.           \dobypara       The drawing object is paragraph relative in the y-
  4514.                           direction.
  4515.  
  4516.           \dobymargin     The drawing object is margin relative in the y-
  4517.                           direction.
  4518.  
  4519.           \dodhgtN        The drawing object is positioned at the following
  4520.                           numeric address in the z-ordering.
  4521.  
  4522.           Drawing Primitives
  4523.  
  4524.           \dpgroup        Begin group of drawing primitives.
  4525.  
  4526.           \dpcountN       Number of drawing primitives in the current group.
  4527.  
  4528.           \dpendgroup     End group of drawing primitives.
  4529.  
  4530.           \dparc          Arc drawing primitive.
  4531.  
  4532.  
  4533.  
  4534.  
  4535.  
  4536.                          Microsoft Product Support Services
  4537.  
  4538.  
  4539.                                                                      Page 74
  4540.  
  4541.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  4542.  
  4543.           Control word    Definition
  4544.           --------------- -------------------------------------------------
  4545.           \dpcallout      Callout drawing primitive, which consists of both
  4546.                           a polyline and a text box.
  4547.  
  4548.           \dpellipse      Ellipse drawing primitive.
  4549.  
  4550.           \dpline         Line drawing primitive.
  4551.  
  4552.           \dppolygon      Polygon drawing primitive (closed polyline).
  4553.  
  4554.           \dppolyline     Polyline drawing primitive.
  4555.  
  4556.           \dprect         Rectangle drawing primitive.
  4557.  
  4558.           \dptxbx         Text box drawing primitive.
  4559.  
  4560.           Position and Size
  4561.  
  4562.           \dpxN           X-offset of the drawing primitive from its anchor.
  4563.  
  4564.           \dpxsizeN       X-size of the drawing primitive.
  4565.  
  4566.           \dpyN           Y-offset of the drawing primitive from its anchor.
  4567.  
  4568.           \dpysizeN       Y-size of the drawing primitive.
  4569.  
  4570.           Callouts
  4571.  
  4572.           \dpcoaN         Angle of callout's diagonal line is restricted to
  4573.                           one of the following: 0, 30, 45, 60, or 90. If
  4574.                           this control word is absent, the callout has an
  4575.                           arbitrary angle, indicated by the coordinates of
  4576.                           its primitives.
  4577.  
  4578.           \dpcoaccent     Accent bar on callout (vertical bar between
  4579.                           polyline and text box).
  4580.  
  4581.           \dpcobestfit    Best fit callout (x-length of each line in callout
  4582.                           is similar).
  4583.  
  4584.           \dpcoborder     Visible border on callout text box.
  4585.  
  4586.           \dpcodabsN      Absolute distance-attached polyline. N is the
  4587.                           offset in twips from the corner that an auto-
  4588.                           attached callout would attach to.
  4589.  
  4590.           \dpcodbottom    Bottom-attached polyline.
  4591.  
  4592.           \dpcodcenter    Center-attached polyline.
  4593.  
  4594.           \dpcodtop       Top-attached callout.
  4595.  
  4596.  
  4597.  
  4598.  
  4599.                          Microsoft Product Support Services
  4600.  
  4601.  
  4602.                                                                      Page 75
  4603.  
  4604.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  4605.  
  4606.           Control word    Definition
  4607.           --------------- -------------------------------------------------
  4608.           \dpcolengthN    Length of callout.
  4609.  
  4610.           \dpcominusx     Text box falls in quadrants II or III relative to
  4611.                           polyline origin.
  4612.  
  4613.           \dpcominusy     Text box falls in quadrants III or IV relative to
  4614.                           polyline origin.
  4615.  
  4616.           \dpcooffsetN    Offset of callout. This is the distance between
  4617.                           the end of the polyline and the edge of the text
  4618.                           box.
  4619.  
  4620.           \dpcosmarta     Auto-attached callout. Polyline will attach to
  4621.                           either the top or bottom of the text box depending
  4622.                           on the relative quadrant.
  4623.  
  4624.           \dpcotdouble    Double line callout.
  4625.  
  4626.           \dpcotright     Right angle callout.
  4627.  
  4628.           \dpcotsingle    Single line callout.
  4629.  
  4630.           \dpcottriple    Triple line callout.
  4631.  
  4632.           Text Boxes and Rectangles
  4633.  
  4634.           \dptxbxmarN     Internal margin of the text box.
  4635.  
  4636.           \dptxbxtext     Group that contains the text of the text box.
  4637.  
  4638.           \dproundr       Rectangle is a round rectangle.
  4639.  
  4640.           Lines and Polylines
  4641.  
  4642.           \dpptxN         X-coordinate of the current vertex (only for lines
  4643.                           and polylines). The coordinate order for a point
  4644.                           must be x, y.
  4645.  
  4646.           \dpptyN         Y-coordinate of the current vertex (only for lines
  4647.                           and polylines). The coordinate order for a point
  4648.                           must be x, y.
  4649.  
  4650.           \dppolycountN   Number of vertices in polyline drawing primitive.
  4651.  
  4652.           Arcs
  4653.  
  4654.           \dparcflipx     This indicates that the end point of the arc is to
  4655.                           the right of the start point. Arcs are
  4656.                           drawn counter-clockwise.
  4657.  
  4658.  
  4659.  
  4660.  
  4661.  
  4662.                          Microsoft Product Support Services
  4663.  
  4664.  
  4665.                                                                      Page 76
  4666.  
  4667.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  4668.  
  4669.           Control word    Definition
  4670.           --------------- -------------------------------------------------
  4671.           \dparcflipy     This indicates that the end point of the arc is
  4672.                           below the start point. Arcs are drawn counter-
  4673.                           clockwise.
  4674.  
  4675.           Line Style
  4676.  
  4677.           \dplinecobN     Blue value for line color.
  4678.  
  4679.           \dplinecogN     Green value for line color.
  4680.  
  4681.           \dplinecorN     Red value for line color.
  4682.  
  4683.           \dplinepal      Render line color using the PALETTERGB macro
  4684.                           instead of the RGB macro in Windows.
  4685.  
  4686.           \dplinedado     Dashed-dotted line style.
  4687.  
  4688.           \dplinedadodo   Dashed-dotted-dotted line style.
  4689.  
  4690.           \dplinedash     Dashed line style.
  4691.  
  4692.           \dplinedot      Dotted line style.
  4693.  
  4694.           \dplinegrayN    Grayscale value for line color (in half-
  4695.                           percentages).
  4696.  
  4697.           \dplinehollow   Hollow line style (no line color).
  4698.  
  4699.           \dplinesolid    Solid line style.
  4700.  
  4701.           \dplinewN       Thickness of line (in twips).
  4702.  
  4703.           Arrow Style
  4704.  
  4705.           \dpaendhol      Hollow end arrow (lines only).
  4706.  
  4707.           \dpaendlN       Length of end arrow, relative to pen width:
  4708.  
  4709.                           1   Small
  4710.  
  4711.                           2   Medium
  4712.  
  4713.                           3   Large
  4714.  
  4715.           \dpaendsol      Solid end arrow (lines only).
  4716.  
  4717.  
  4718.  
  4719.  
  4720.  
  4721.  
  4722.  
  4723.  
  4724.  
  4725.                          Microsoft Product Support Services
  4726.  
  4727.  
  4728.                                                                      Page 77
  4729.  
  4730.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  4731.  
  4732.           Control word    Definition
  4733.           --------------- -------------------------------------------------
  4734.           \dpaendwN       Width of end arrow, relative to pen width:
  4735.  
  4736.                           1   Small
  4737.  
  4738.                           2   Medium
  4739.  
  4740.                           3   Large
  4741.  
  4742.           \dpastarthol    Hollow start arrow (lines only).
  4743.  
  4744.           \dpastartlN     Length of start arrow, relative to pen width:
  4745.  
  4746.                           1   Small
  4747.  
  4748.                           2   Medium
  4749.  
  4750.                           3   Large
  4751.  
  4752.           \dpastartsol    Solid start arrow (lines only).
  4753.  
  4754.           \dpastartwN     Width of start arrow, relative to pen width:
  4755.  
  4756.                           1   Small
  4757.  
  4758.                           2   Medium
  4759.  
  4760.                           3   Large
  4761.  
  4762.           Fill Pattern
  4763.  
  4764.           \dpfillbgcbN    Blue value for background fill color.
  4765.  
  4766.           \dpfillbgcgN    Green value for background fill color.
  4767.  
  4768.           \dpfillbgcrN    Red value for background fill color.
  4769.  
  4770.           \dpfillbgpal    Render fill background color using the PALETTERGB
  4771.                           macro instead of the RGB macro in Windows.
  4772.  
  4773.           \dpfillbggrayN  Grayscale value for background fill (in half-
  4774.                           percentages).
  4775.  
  4776.           \dpfillfgcbN    Blue value for foreground fill color.
  4777.  
  4778.           \dpfillfgcgN    Green value for foreground fill color.
  4779.  
  4780.           \dpfillfgcrN    Red value for foreground fill color.
  4781.  
  4782.           \dpfillfgpal    Render fill foreground color using the PALETTERGB
  4783.                           macro instead of the RGB macro in Windows.
  4784.  
  4785.  
  4786.  
  4787.  
  4788.                          Microsoft Product Support Services
  4789.  
  4790.  
  4791.                                                                      Page 78
  4792.  
  4793.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  4794.  
  4795.           Control word    Definition
  4796.           --------------- -------------------------------------------------
  4797.           \dpfillfggrayN  Grayscale value for foreground fill (in half-
  4798.                           percentages).
  4799.  
  4800.           \dpfillpatN     Index into a list of fill patterns. See below for
  4801.                           list.
  4802.  
  4803.           Shadow
  4804.  
  4805.           \dpshadow       Current drawing primitive has a shadow.
  4806.  
  4807.           \dpshadxN       X-offset of the shadow.
  4808.  
  4809.           \dpshadyN       Y-offset of the shadow.
  4810.  
  4811.        The following values are available for specifying fill patterns in
  4812.        drawing objects with the \dpfillpat control word.
  4813.  
  4814.           Value   Fill pattern
  4815.  
  4816.           0       Clear (no pattern)
  4817.           (zero)
  4818.  
  4819.           1       Solid (100%)
  4820.  
  4821.           2       5%
  4822.  
  4823.           3       10%
  4824.  
  4825.           4       20%
  4826.  
  4827.           5       25%
  4828.  
  4829.           6       30%
  4830.  
  4831.           7       40%
  4832.  
  4833.           8       50%
  4834.  
  4835.           9       60%
  4836.  
  4837.           10      70%
  4838.  
  4839.           11      75%
  4840.  
  4841.           12      80%
  4842.  
  4843.           13      90%
  4844.  
  4845.           14      Dark horizontal lines
  4846.  
  4847.  
  4848.  
  4849.  
  4850.  
  4851.                          Microsoft Product Support Services
  4852.  
  4853.  
  4854.                                                                      Page 79
  4855.  
  4856.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  4857.  
  4858.           Value   Fill pattern
  4859.  
  4860.           15      Dark vertical lines
  4861.  
  4862.           16      Dark left-diagonal lines (\\\)
  4863.  
  4864.           17      Dark right-diagonal lines (///)
  4865.  
  4866.           18      Dark grid lines
  4867.  
  4868.           19      Dark trellis lines
  4869.  
  4870.           20      Light horizontal lines
  4871.  
  4872.           21      Light vertical lines
  4873.  
  4874.           22      Light left-diagonal lines (\\\)
  4875.  
  4876.           23      Light right-diagonal lines (///)
  4877.  
  4878.           24      Light grid lines
  4879.  
  4880.           25      Light trellis lines
  4881.  
  4882.        Footnotes
  4883.  
  4884.        The \footnote control word introduces a footnote. Footnotes are
  4885.        destinations in RTF. A footnote is anchored to the character that
  4886.        immediately precedes the footnote destination (that is, the footnote
  4887.        moves with the character to which it is anchored). If automatic
  4888.        footnote numbering is defined, the destination can be preceded by a
  4889.        footnote reference character, identified by the control word \chftn.
  4890.        No Microsoft product supports footnotes within headers, footers, or
  4891.        annotations. Placing a footnote within headers, footers, or
  4892.        annotations will often result in a corrupt document.
  4893.  
  4894.        Footnotes have the following syntax.
  4895.  
  4896.           <foot>      '{\*' \footnote <para>+ '}'
  4897.  
  4898.        Here is an example of a destination containing footnotes:
  4899.  
  4900.           \ftnbj\ftnrestart \sectd \linemod0\linex0\endnhere \pard\plain
  4901.  
  4902.           \ri1170 \fs20 {\pu6 Mead's landmark study has been amply
  4903.           annotated.\chftn
  4904.  
  4905.           {\*\footnote \pard\plain \s246 \fs20 {\up6\chftn }See Sahlins,
  4906.           Bateson, and
  4907.  
  4908.           Geertz for a complete bibliography.}
  4909.  
  4910.           It was her work in America during the Second World War, however,
  4911.  
  4912.  
  4913.  
  4914.                          Microsoft Product Support Services
  4915.  
  4916.  
  4917.                                                                      Page 80
  4918.  
  4919.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  4920.  
  4921.           that forms
  4922.  
  4923.           the basis for the paper. As others have noted, \chftn
  4924.  
  4925.           {\*\footnote \pard\plain \s246 \fs20 {\up6\chftn}
  4926.  
  4927.           A complete bibliography will be found at the end of this chapter.}
  4928.  
  4929.           this period was a turning point for Margaret Mead.}
  4930.  
  4931.           \par
  4932.  
  4933.        To indicate endnotes, the following combination is emitted:
  4934.        \footnote\ftnalt. Existing readers will ignore the \ftnalt control
  4935.        word and treat everything as a footnote.
  4936.  
  4937.        For other control words relating to footnotes, see the sections titled
  4938.        "Document Formatting Properties" (page 24), "Section Formatting
  4939.        Properties" (page 30), and "Special Characters" (page 58) in this
  4940.        Application Note.
  4941.  
  4942.        Annotations
  4943.  
  4944.        RTF annotations have two parts; the author ID (introduced by the
  4945.        control word \atnid) and the annotation text (introduced by the
  4946.        control word \annotation); there is no group enclosing both parts. No
  4947.        Microsoft product supports annotations within headers, footers, or
  4948.        footnotes. Placing an annotation within headers, footers, or footnotes
  4949.        will often result in a corrupt document. Each part of the annotation
  4950.        is an RTF destination. Annotations are anchored to the character that
  4951.        immediately precedes the annotation.
  4952.  
  4953.        If an annotation is associated with an annotation bookmark, the
  4954.        following two destination control words precede and follow the
  4955.        bookmark. The alphanumeric string N, such as a long integer,
  4956.        represents the bookmark name.
  4957.  
  4958.           <atrfstart> '{\*' \atrfstart N '}'
  4959.  
  4960.           < atrfend>  '{\*' \atrfend N '}'
  4961.  
  4962.        Annotations have the following syntax:
  4963.  
  4964.           <annot>     <annotid> <atnauthor> <atntime>? \chatn <atnicn>?
  4965.                       <annotdef>
  4966.  
  4967.           <annotid>   '{\*' \atnid #PCDATA '}'
  4968.  
  4969.           < atnauthor '{\*' \atnauthor #PCDATA '}'
  4970.  
  4971.           <annotdef>  '{\*' \annotation <atnref> <para>+ '}'
  4972.  
  4973.  
  4974.  
  4975.  
  4976.  
  4977.                          Microsoft Product Support Services
  4978.  
  4979.  
  4980.                                                                      Page 81
  4981.  
  4982.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  4983.  
  4984.           < atnref>   '{\*' \atnref N '}'
  4985.  
  4986.           <atntime>   '{\*' \atntime <time> '}'
  4987.  
  4988.           <atnicn>    '{\*' \atnicn <pict> '}'
  4989.  
  4990.        An example of annotation text follows:
  4991.  
  4992.           An example of a paradigm might be Newtonian physics or
  4993.  
  4994.           Darwinian biology.{\v\fs16 {\atnid bz}\chatn{\*\annotation
  4995.  
  4996.           \pard\plain \s224 \fs20 {\field{\fldinst page \\#'"Page:
  4997.  
  4998.           '#'\line'"}{\fldrslt}}{\fs16 \chatn }
  4999.  
  5000.           How about some examples that deal with social science?
  5001.  
  5002.           That's what this paper is about.}}
  5003.  
  5004.        Annotations may have optional time stamps (contained in the \atntime
  5005.        destination) or icons (contained in the \atnicn destination).
  5006.  
  5007.        Fields
  5008.  
  5009.        The \field control word introduces a field destination, which contains
  5010.        the text of Word for Windows fields.
  5011.  
  5012.        Fields have the following syntax:
  5013.  
  5014.           <field>     '{' \field <fieldmod>? <fieldinst> <fieldrslt> '}'
  5015.  
  5016.           <fieldmod>  \flddirty? & \fldedit? & \fldlock? & \fldpriv?
  5017.  
  5018.           <fieldinst> '{\*' \fldinst <char>+ <fldalt>? '}'
  5019.  
  5020.           <fldalt>    \fldalt
  5021.  
  5022.           <fieldrslt> '{\*' \fldrslt <para>+ '}'
  5023.  
  5024.        There are several control words that alter the interpretation of the
  5025.        field. These control words are listed in the following table.
  5026.  
  5027.           Control word Meaning
  5028.           ------------ -----------------------------------------------------
  5029.           \flddirty    A formatting change has been made to the field result
  5030.                        since the field was last updated.
  5031.  
  5032.           \fldedit     Text has been added to, or removed from, the field
  5033.                        result since the field was last updated.
  5034.  
  5035.           \fldlock     Field is locked and cannot be updated.
  5036.  
  5037.  
  5038.  
  5039.  
  5040.                          Microsoft Product Support Services
  5041.  
  5042.  
  5043.                                                                      Page 82
  5044.  
  5045.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  5046.  
  5047.           Control word Meaning
  5048.           ------------ -----------------------------------------------------
  5049.           \fldpriv     Result is not in a form suitable for display (for
  5050.                        example, binary data used by fields whose result is a
  5051.                        picture).
  5052.  
  5053.        Two subdestinations are required within the \field destination. They
  5054.        must be enclosed in braces ({ }) and begin with the following control
  5055.        words.
  5056.  
  5057.           Control word Meaning
  5058.           ------------ -----------------------------------------------------
  5059.           \fldinst     Field instructions. This is a destination control
  5060.                        word.
  5061.  
  5062.           \fldrslt     Most recent calculated result of the field. This is a
  5063.                        destination control word.
  5064.  
  5065.        If the instruction for a field contains a filename, then the \cpg
  5066.        control can be used to define the character set of the filename. See
  5067.        ``Code Page Support'' on page 15 of this Application Note for details.
  5068.  
  5069.        The \fldrslt control word should be included even if no result has
  5070.        been calculated because most readers (even those readers that do not
  5071.        recognize fields) can generally include the value of the \fldrslt
  5072.        destination in the document.
  5073.  
  5074.        An example of some field text follows:
  5075.  
  5076.           {\field\fldedit{\fldinst author}{\fldrslt Joe Smith}}\par\pard
  5077.  
  5078.           {\field{\fldinst time \\@ "h:mm AM/PM"}{\fldrslt 8:12 AM}}
  5079.  
  5080.        You can use the \fldalt control word to specify that the given field
  5081.        reference is to an endnote. For example, the following field in RTF is
  5082.        a reference to a footnote:
  5083.  
  5084.           {\field{\*\fldinst NOTEREF _RefNumber } {\fldrslt 1}}
  5085.  
  5086.        The following is an example of a reference to an endnote:
  5087.  
  5088.           {\field{\*\fldinst NOTEREF _RefNumber \fldalt } {\fldrslt I}}
  5089.  
  5090.        If the specified field is a form field, the \*\datafield destination
  5091.        appears as a part of <char> and contains the binary data of a form
  5092.        field instruction. For example:
  5093.  
  5094.           {\field{\*\fldinst {\*\bkmkstart Text1} FORMTEXT {{\*\datafield
  5095.  
  5096.           00000000000000000554657874310008476565207768697a0000000000000000000
  5097.           000}}}{\fldrslt Default Result}}{\*\bkmkend Text1}
  5098.  
  5099.  
  5100.  
  5101.  
  5102.  
  5103.                          Microsoft Product Support Services
  5104.  
  5105.  
  5106.                                                                      Page 83
  5107.  
  5108.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  5109.  
  5110.        Note that the \datafield destination requires the \* prefix.
  5111.  
  5112.        Index Entries
  5113.  
  5114.        The \xe control word introduces an index entry. Index entries in RTF
  5115.        are destinations. An index entry has the following syntax:
  5116.  
  5117.           <idx>       '{' \xe (\xef? & \bxe? & \ixe?) <char>+ (<txe> |
  5118.                       <rxe>)? '}'
  5119.  
  5120.           <txe>       '{' \txe <char>+ '}'
  5121.  
  5122.           <rxe>       '{' \rxe #PCDATA '}'
  5123.  
  5124.        If the text of the index entry is not formatted as hidden text with
  5125.        the \v control word, the text is put into the document as well as into
  5126.        the index. For more information on the \v control word, see "Character
  5127.        Formatting Properties" on page 51 of this Application Note. Similarly,
  5128.        the text of the \txe subdestination, described later in this section,
  5129.        becomes part of the document if it is not formatted as hidden text.
  5130.  
  5131.        The following control words may also be used.
  5132.  
  5133.           Control word   Meaning
  5134.           ------------   ---------------------------------------------------
  5135.                          --
  5136.           \xefN          Allows multiple indexes within the same document. N
  5137.                          is an integer that corresponds to the ASCII value
  5138.                          of a letter between A and Z.
  5139.  
  5140.           \bxe           Formats the page number or cross-reference in bold.
  5141.  
  5142.           \ixe           Formats the page number or cross-reference in
  5143.                          italic.
  5144.  
  5145.           \txe Text      Text argument to be used instead of a page number.
  5146.                          This is a destination control word.
  5147.  
  5148.           \rxe           Text argument is a bookmark for the range of page
  5149.           BookmarkName   numbers. This is a destination control word.
  5150.  
  5151.        Table of Contents Entries
  5152.  
  5153.        The \tc control word introduces a table of contents entry, which can
  5154.        be used to build the actual table of contents. The \tcn control word
  5155.        marks a table of contents entry that will not have a page number
  5156.        associated with it; this is used in place of \tc for such entries.
  5157.        Table of contents entries are destinations, and they have the
  5158.        following syntax:
  5159.  
  5160.           <toc>       '{' \tc | \tcn ( \tcf? & \tcl?) <char>+ '}'
  5161.  
  5162.        As with index entries, text that is not formatted as hidden with the
  5163.  
  5164.  
  5165.  
  5166.                          Microsoft Product Support Services
  5167.  
  5168.  
  5169.                                                                      Page 84
  5170.  
  5171.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  5172.  
  5173.        \v character-formatting control word is put into the document. The
  5174.        following control words can also be used in this destination.
  5175.  
  5176.           Control word Meaning
  5177.           ------------ -----------------------------------------------------
  5178.           \tcfN        Type of table being compiled; N is mapped by existing
  5179.                        Microsoft software to a letter between A and Z (the
  5180.                        default is 67, which maps to C, used for tables of
  5181.                        contents).
  5182.  
  5183.           \tclN        Level number (the default is 1).
  5184.  
  5185.        Bidirectional Language Support
  5186.  
  5187.        RTF supports bidirectional writing orders for languages such as
  5188.        Arabic. The controls are described below (as well as in the
  5189.        appropriate sections throughout this Application Note). Also refer to
  5190.        the associated character properties defined in ``Associated Character
  5191.        Properties'' on page 56 of this Application Note.
  5192.  
  5193.        All the control words relating to bidirectional language support are
  5194.        repeated here for convenience.
  5195.  
  5196.           Control word Meaning
  5197.           ------------ -----------------------------------------------------
  5198.           \rtlch       The character data following this control word will be
  5199.                        treated as a right-to-left run.
  5200.  
  5201.           \ltrch       The character data following this control word will be
  5202.                        treated as a left-to-right run (the default).
  5203.  
  5204.           \rtlmark     The following characters should be displayed from
  5205.                        right to left.
  5206.  
  5207.           \ltrmark     The following characters should be displayed from left
  5208.                        to right.
  5209.  
  5210.           \rtlpar      Text in this paragraph will be displayed with right-
  5211.                        to-left precedence
  5212.  
  5213.           \ltrpar      Text in this paragraph will be displayed with left-to-
  5214.                        right precedence. This is the default.
  5215.  
  5216.           \rtlrow      Cells in this table row will have right-to-left
  5217.                        precedence.
  5218.  
  5219.           \ltrrow      Cells in this table row will have left-to-right
  5220.                        precedence. This is the default.
  5221.  
  5222.           \rtlsect     This section will thread columns from right to left.
  5223.  
  5224.  
  5225.  
  5226.  
  5227.  
  5228.  
  5229.                          Microsoft Product Support Services
  5230.  
  5231.  
  5232.                                                                      Page 85
  5233.  
  5234.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  5235.  
  5236.           Control word Meaning
  5237.           ------------ -----------------------------------------------------
  5238.           \ltrsect     This section will thread columns from left to right.
  5239.                        This is the default.
  5240.  
  5241.           \rtldoc      Text in this document will be displayed from right to
  5242.                        left unless overridden by a more specific control.
  5243.  
  5244.           \ltrdoc      Text in this document will be displayed from left to
  5245.                        right unless overridden by a more specific control.
  5246.                        This is the default.
  5247.  
  5248.           \zwj         Zero-width joiner. This is used for ligating
  5249.                        characters.
  5250.  
  5251.           \zwnj        Zero-width nonjoiner. This is used for unligating
  5252.                        characters.
  5253.  
  5254.  
  5255.  
  5256.  
  5257.  
  5258.  
  5259.  
  5260.  
  5261.  
  5262.  
  5263.  
  5264.  
  5265.  
  5266.  
  5267.  
  5268.  
  5269.  
  5270.  
  5271.  
  5272.  
  5273.  
  5274.  
  5275.  
  5276.  
  5277.  
  5278.  
  5279.  
  5280.  
  5281.  
  5282.  
  5283.  
  5284.  
  5285.  
  5286.  
  5287.  
  5288.  
  5289.  
  5290.  
  5291.  
  5292.                          Microsoft Product Support Services
  5293.  
  5294.  
  5295.                                                                      Page 87
  5296.  
  5297.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  5298.  
  5299.        APPENDIX A: SAMPLE RTF READER APPLICATION
  5300.  
  5301.        The GC0165 disk included with this Application Note contains the
  5302.        sample RTF reader program RTFREADR.EXE, which will help you create an
  5303.        RTF reader for your own application when used in conjunction with the
  5304.        Microsoft Rich Text Format Specification and the information below.
  5305.  
  5306.           Note: The sample RTF reader is not a for-sale product, and
  5307.           Microsoft does not provide technical or any other type of support
  5308.           for the sample RTF reader code or the RTF specification.
  5309.  
  5310.        If this shipment has arrived in unsatisfactory condition, please call
  5311.        Microsoft Product Support Services (PSS). In the United States, call
  5312.        (206) 462-WORD (9673) between 6:00 A.M. and 6:00 P.M. Pacific time.
  5313.        Outside the United States, contact the Microsoft subsidiary for your
  5314.        area. To locate your subsidiary, call Microsoft International Customer
  5315.        Service at (206) 936-8661.
  5316.  
  5317.        How to Write an RTF Reader
  5318.  
  5319.        There are three basic things that an RTF reader must do:
  5320.  
  5321.        1. Separate text from RTF controls
  5322.  
  5323.        2. Parse an RTF control
  5324.  
  5325.        3. Dispatch an RTF control
  5326.  
  5327.        Separating text from RTF controls is relatively simple, as all RTF
  5328.        controls begin with a backslash. Therefore, any incoming character
  5329.        that is not a backslash is text and will be handled as text. (Of
  5330.        course, what one does with that text may be relatively complicated.)
  5331.  
  5332.        Parsing an RTF control is also relatively simple. An RTF control is
  5333.        either (a) a sequence of alphabetic characters followed by an optional
  5334.        numeric parameter, or (b) a single non-alphanumeric character.
  5335.  
  5336.        Dispatching an RTF control, on the other hand, is relatively
  5337.        complicated. A recursive-descent parser tends to be overly strict
  5338.        because RTF is intentionally vague about the order of various
  5339.        properties relative to one another. However, whatever method you use
  5340.        to dispatch an RTF control, your reader should do the following:
  5341.  
  5342.        . Ignore keywords you don't understand.
  5343.  
  5344.          Many readers crash when they come across an unknown RTF control.
  5345.          Because Microsoft is continually adding new RTF controls, this
  5346.          limits an RTF reader to working with the RTF from one particular
  5347.          product (usually some version of Word for Windows).
  5348.  
  5349.        . Always understand \*.
  5350.  
  5351.          One of the most important things an RTF reader can do is to
  5352.  
  5353.  
  5354.  
  5355.                          Microsoft Product Support Services
  5356.  
  5357.  
  5358.                                                                      Page 88
  5359.  
  5360.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  5361.  
  5362.          understand the \* control. This control introduces a destination
  5363.          that is not part of the document. It tells the RTF reader that if
  5364.          the reader does not understand the next control word, then it should
  5365.          skip the entire enclosing group. If your reader follows this rule
  5366.          and the one above, your reader will be able to cope with any future
  5367.          change to RTF short of a complete rewrite.
  5368.  
  5369.        . Remember that binary data can occur when you're skipping RTF.
  5370.  
  5371.          A simple way to skip a group in RTF is to keep a running count of
  5372.          the opening curly braces that the reader has encountered in the RTF
  5373.          stream. When the reader sees an opening curly brace, it increments
  5374.          the count; when the reader sees a closing curly brace, it decrements
  5375.          the count. When the count becomes negative, the end of the group has
  5376.          been found. Unfortunately, this doesn't work when the RTF file
  5377.          contains a \bin control; the reader must explicitly check each
  5378.          control word found to see if it's a \bin control, and--if a \bin
  5379.          control is found--skip that many bytes before resuming its scanning
  5380.          for curly braces.
  5381.  
  5382.        A Sample RTF Reader Implementation
  5383.  
  5384.        The Microsoft Word Processing Conversions group uses a table-driven
  5385.        approach to reading RTF. This approach allows the most flexibility in
  5386.        reading RTF, with the corresponding problem that it's difficult to
  5387.        detect incorrect RTF. An RTF reader that is based on this approach is
  5388.        presented below. This reader works exactly as described in the RTF
  5389.        specification and uses the principles of operation described in the
  5390.        RTF specification. This reader is designed to be simple to understand
  5391.        but is not intended to be very efficient. This RTF reader also
  5392.        implements the three design principles listed in the previous section.
  5393.  
  5394.        The RTF reader consists of four files:
  5395.  
  5396.        . RTFDECL.H, which contains the prototypes for all the functions in
  5397.          the RTF reader
  5398.  
  5399.        . RTFTYPE.H, which contains the types used in the RTF reader
  5400.  
  5401.        . RTFREADR.C, which contains the main program, the main loop of the
  5402.          RTF reader, and the RTF control parser
  5403.  
  5404.        . RTFACTN.C, which contains the dispatch routines for the RTF reader
  5405.  
  5406.        RTFDECL.H and RTFREADR.C
  5407.  
  5408.        RTFDECL.H is straightforward and requires little explanation.
  5409.  
  5410.        RTFREADR.C is also reasonably straightforward; the function ecRtfParse
  5411.        separates text from RTF controls and handles text, and the function
  5412.        ecParseRtfKeyword parses an RTF control and also collects any
  5413.        parameter that follows the RTF control.
  5414.  
  5415.  
  5416.  
  5417.  
  5418.                          Microsoft Product Support Services
  5419.  
  5420.  
  5421.                                                                      Page 89
  5422.  
  5423.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  5424.  
  5425.        RTFTYPE.H
  5426.  
  5427.        RTFTYPE.H begins by declaring a sample set of character, paragraph,
  5428.        section, and document properties. These structures are present to
  5429.        demonstrate how the dispatch routines can modify any particular
  5430.        property and are not actually used to format text.
  5431.  
  5432.        For example, the following enumeration describes which destination
  5433.        text should be routed to:
  5434.  
  5435.           typedef enum { rdsNorm, rdsSkip } RDS;
  5436.  
  5437.        Because this is just a sample RTF reader, there are only two
  5438.        destinations; a more complicated reader would add an entry to this
  5439.        enumeration for each destination supported (for example--headers,
  5440.        footnotes, endnotes, annotations, bookmarks, and pictures).
  5441.  
  5442.        The following enumeration describes the internal state of the RTF
  5443.        parser:
  5444.  
  5445.           typedef enum { risNorm, risBin, risHex } RIS;
  5446.  
  5447.        This is entirely separate from the state of the dispatch routines and
  5448.        the destination state; other RTF readers may not necessarily have
  5449.        anything similar to this.
  5450.  
  5451.        The following structure encapsulates the state that must be saved at a
  5452.        group start and restored at a group end:
  5453.  
  5454.           typedef struct save
  5455.           {
  5456.           struct save *pNext;
  5457.           CHP chp;
  5458.           PAP pap;
  5459.           SEP sep;
  5460.           DOP dop;
  5461.           RDS rds;
  5462.           RIS ris;
  5463.           } SAVE;
  5464.  
  5465.  
  5466.        The following enumeration describes a set of classes for RTF controls:
  5467.  
  5468.           typedef enum {kwdChar, kwdDest, kwdProp, kwdSpec} KWD;
  5469.  
  5470.        Use kwdChar for controls that represent special characters (such as \-
  5471.        , \{, or \}).
  5472.  
  5473.        Use kwdDest for controls that introduce RTF destinations.
  5474.  
  5475.        Use kwdProp for controls that modify some sort of property.
  5476.  
  5477.  
  5478.  
  5479.  
  5480.  
  5481.                          Microsoft Product Support Services
  5482.  
  5483.  
  5484.                                                                      Page 90
  5485.  
  5486.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  5487.  
  5488.        Use kwdSpec for controls that need to run some specialized code.
  5489.  
  5490.        The following enumeration defines the number of PROP structures
  5491.        (described below) that will be used. There will typically be an iprop
  5492.        for every field in the character, paragraph, section, and document
  5493.        properties.
  5494.  
  5495.           typedef enum {ipropBold, ipropItalic, ipropUnderline, ipropLeftInd,
  5496.           ipropRightInd, ipropFirstInd, ipropCols, ipropPgnX, ipropPgnY,
  5497.           ipropXaPage, ipropYaPage, ipropXaLeft, ipropXaRight,
  5498.           ipropYaTop, ipropYaBottom, ipropPgnStart, ipropSbk,
  5499.           ipropPgnFormat, ipropFacingp, ipropLandscape, ipropJust,
  5500.           ipropPard, ipropPlain,
  5501.           ipropMax} IPROP;
  5502.        The following structure is a very compact way to describe how to
  5503.        locate the address of a particular value in one of the property
  5504.        structures:
  5505.  
  5506.           typedef enum {actnSpec, actnByte, actnWord} ACTN;
  5507.           typedef enum {propChp, propPap, propSep, propDop} PROPTYPE;
  5508.  
  5509.           typedef struct propmod
  5510.           {
  5511.           ACTN actn;
  5512.           PROPTYPE prop;
  5513.           int offset;
  5514.           } PROP;
  5515.        The actn field describes the width of the value being described: if
  5516.        the value is a byte, then actn is actnByte; if the value is a word,
  5517.        then actn is actnWord; if the value is neither a byte nor a word, then
  5518.        you can use actnSpec to indicate that some C code needs to be run to
  5519.        set the value. The prop field indicates which property structure is
  5520.        being described; propChp indicates that the value is located within
  5521.        the CHP structure; propPap indicates that the value is located within
  5522.        the PAP structure, and so on. Finally, the offset field contains the
  5523.        offset of the value from the start of the structure. The offsetof()
  5524.        macro is usually used to initialize this field.
  5525.  
  5526.        The following structure describes how to parse a particular RTF
  5527.        control:
  5528.  
  5529.           typedef enum {ipfnBin, ipfnHex, ipfnSkipDest } IPFN;
  5530.           typedef enum {idestPict, idestSkip } IDEST;
  5531.  
  5532.           typedef struct symbol
  5533.           {
  5534.           char *szKeyword;
  5535.           int dflt;
  5536.           bool fPassDflt;
  5537.           KWD kwd;
  5538.           int idx;
  5539.           } SYM;
  5540.        szKeyword points to the RTF control being described; kwd describes the
  5541.  
  5542.  
  5543.  
  5544.                          Microsoft Product Support Services
  5545.  
  5546.  
  5547.                                                                      Page 91
  5548.  
  5549.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  5550.  
  5551.        class of the particular RTF control (described above); dflt is the
  5552.        default value for this control, and fPassDflt should be nonzero if the
  5553.        value in dflt should be passed to the dispatch routine. (fPassDflt is
  5554.        only nonzero for keywords that normally set a particular value. For
  5555.        example, the various section break controls typically have nonzero
  5556.        fPassDflt controls, but controls that take parameters should not.)
  5557.  
  5558.        Idx is a generalized index; its use depends on the kwd being used for
  5559.        this control.
  5560.  
  5561.        . If kwd is kwdChar, then idx is the character that should be output.
  5562.  
  5563.        . If kwd is kwdDest, then idx is the idest for the new destination.
  5564.  
  5565.        . If kwd is kwdProp, then idx is the iprop for the appropriate
  5566.          property.
  5567.  
  5568.        . If kwd is kwdSpec, then idx is an ipfn for the appropriate function.
  5569.  
  5570.        With this structure, it is very simple to dispatch an RTF keyword.
  5571.        Once the reader isolates the RTF keyword and its (possibly associated)
  5572.        value, the reader then searches an array of SYM structures to find the
  5573.        RTF keyword. If the keyword is not found, the reader ignores it,
  5574.        unless the previous control was \*, in which case the reader must scan
  5575.        past an entire group.
  5576.  
  5577.        If the keyword is found, the reader then uses the kwd value from the
  5578.        SYM structure to determine what to do. This is, in fact, exactly what
  5579.        the function ecTranslateKeyword in the file RTFACTN.C does.
  5580.  
  5581.        The RTFACTN.C File
  5582.  
  5583.        RTFACTN.C contains the tables describing the properties and keywords,
  5584.        and the routines to evaluate properties (ecApplyPropChange) and to
  5585.        dispatch keywords (ecTranslateKeyword).
  5586.  
  5587.        The tables are the keys to understanding the RTF dispatch routines.
  5588.        The following are some sample entries from both tables, along with a
  5589.        brief explanation of each entry.
  5590.  
  5591.        The Property Table. This table must have an entry for every iprop.
  5592.  
  5593.           actnByte,   propChp,    offsetof(CHP, fBold),       // ipropBold
  5594.  
  5595.              This property says that the ipropBold property is a byte
  5596.              parameter bound to chp.fBold.
  5597.  
  5598.           actnWord,   propPap,    offsetof(PAP, xaRight),     //
  5599.           ipropRightInd
  5600.  
  5601.              This property says that ipropRightInd is a word parameter bound
  5602.              to pap.xaRight.
  5603.  
  5604.  
  5605.  
  5606.  
  5607.                          Microsoft Product Support Services
  5608.  
  5609.  
  5610.                                                                      Page 92
  5611.  
  5612.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  5613.  
  5614.           actnWord,   propSep,    offsetof(SEP, cCols),       // ipropCols
  5615.  
  5616.              This property says that ipropCols is a word parameter bound to
  5617.              sep.cCols.
  5618.  
  5619.           actnSpec,   propChp,    0,                          // ipropPlain
  5620.  
  5621.              This property says that ipropPlain is a special parameter.
  5622.              Instead of directly evaluating it, ecApplyPropChange will run
  5623.              some custom C code to apply a property change.
  5624.  
  5625.        The Keyword Table.
  5626.  
  5627.           "b",        1,      fFalse,     kwdProp,    ipropBold,
  5628.  
  5629.              This structure says that the control \b sets the ipropBold
  5630.              property. Because fPassDflt is false, the reader only uses the
  5631.              default value if the control does not have a parameter. If no
  5632.              parameter is provided, the reader uses a value of 1.
  5633.  
  5634.           "sbknone",  sbkNon, fTrue,      kwdProp,    ipropSbk,
  5635.  
  5636.              This entry says that the control \sbknone sets the ipropSbk
  5637.              property. Since fPassDflt is true, the reader always uses the
  5638.              default value of sbkNon, even if the control has a parameter.
  5639.  
  5640.           "par",      0,      fFalse,     kwdChar,    0x0a,
  5641.  
  5642.              This entry says that the control \par is equivalent to a 0x0a
  5643.              (linefeed) character.
  5644.  
  5645.           "tab",      0,      fFalse,     kwdChar,    0x09,
  5646.  
  5647.              This entry says that the control \tab is equivalent to a 0x09
  5648.              (tab) character.
  5649.  
  5650.           "bin",      0,      fFalse,     kwdSpec,    ipfnBin,
  5651.  
  5652.              This entry says that the control \bin should run some C code.
  5653.              The particular piece of C code can be located by the ipfnBin
  5654.              parameter.
  5655.  
  5656.           "fonttbl",  0,      fFalse,     kwdDest,    idestSkip,
  5657.  
  5658.              This entry says that the control \fonttbl should change to the
  5659.              destination idestSkip.
  5660.  
  5661.        Notes on Implementing Other RTF Features
  5662.  
  5663.        The table-driven approach to dispatching RTF controls used by the
  5664.        sample converter does not implement any syntax checking. For most
  5665.        controls, this is not a problem; a control simply modifies the
  5666.        appropriate property. However, some controls, such as those for tabs
  5667.  
  5668.  
  5669.  
  5670.                          Microsoft Product Support Services
  5671.  
  5672.  
  5673.                                                                      Page 93
  5674.  
  5675.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  5676.  
  5677.        and borders, are dependent on other control words either before or
  5678.        after the current control word.
  5679.  
  5680.        There are some standard techniques for handling these features:
  5681.  
  5682.        Tabs and Other Control Sequences Terminating in a Fixed Control
  5683.  
  5684.        The best way to implement these types of control sequences is to have
  5685.        a global structure that represents the current state of the tab
  5686.        descriptor (or other entity). As the modifiers come in, they modify
  5687.        the various fields of the global structure; when the fixed control at
  5688.        the end of the sequence is dispatched, it adds the entire descriptor
  5689.        and reinitializes the global variable.
  5690.  
  5691.        Borders and Other Control Sequences Beginning with a Fixed Control
  5692.  
  5693.        The best way to implement these types of control sequences is to have
  5694.        a global pointer that is initialized when the fixed control is
  5695.        dispatched; the controls that modify the fixed control then modify
  5696.        fields pointed to by the control.
  5697.  
  5698.        Other Problem Areas in RTF
  5699.  
  5700.        Style Sheets
  5701.  
  5702.        Style sheets can be handled as destinations; however, styles have
  5703.        default values, just as every other control does; RTF readers should
  5704.        be sure to handle a missing style control as the default style value
  5705.        (that is, 0).
  5706.  
  5707.        Property Changes
  5708.  
  5709.        Some RTF readers use various bits of RTF syntax to mark property
  5710.        changes. In particular, they assume that property changes will occur
  5711.        only after a group start, which is not correct. Because there is a
  5712.        variety of ways to represent identical property changes in RTF, RTF
  5713.        readers should look at the changes in the properties and not at any
  5714.        particular way of representing a property change. In particular,
  5715.        properties can be changed explicitly with a control word or implicitly
  5716.        at the end of a group. For example, these three sequences of RTF have
  5717.        exactly the same semantics, and should be translated identically:
  5718.  
  5719.           .  {\b bold \i Bold Italic \i0 Bold again}
  5720.  
  5721.           .  {\b bold {\i Bold Italic }Bold again}
  5722.  
  5723.           .  {\b bold \i Bold Italic \plain\b Bold again}
  5724.  
  5725.        Fields
  5726.  
  5727.        All versions of Microsoft Word for Windows and version 6.0 of
  5728.        Microsoft Word for the Macintosh have fields. If you're writing an RTF
  5729.        reader and expect to do anything with fields, keep the following notes
  5730.  
  5731.  
  5732.  
  5733.                          Microsoft Product Support Services
  5734.  
  5735.  
  5736.                                                                      Page 94
  5737.  
  5738.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  5739.  
  5740.        in mind:
  5741.  
  5742.        . Field instructions may have arbitrary amounts of character
  5743.          formatting and arbitrarily nested groups. While the groups will be
  5744.          properly nested within the field instructions, you may be inside an
  5745.          arbitrary number of groups by the time you know which field you
  5746.          working with. If you then expect to be able to skip to the end of
  5747.          the field instructions, you'll have to know how many groups have
  5748.          started so that you can skip to the end properly.
  5749.  
  5750.        . Some fields, the INCLUDE field in particular, can have section
  5751.          breaks in the field results. If this occurs, then the text after the
  5752.          end of the field does not have the same section properties as the
  5753.          text at the start of the field; the section properties must not be
  5754.          restored when the field results contain section breaks.
  5755.  
  5756.        Tables
  5757.  
  5758.        Tables are probably the trickiest part of RTF to read and write
  5759.        correctly. Because of the way Microsoft word processors implement
  5760.        tables, and the table-driven approach of many Microsoft RTF readers,
  5761.        it is very easy to write tables in RTF that will crash Microsoft word
  5762.        processors when you try to read the RTF. Here are some guidelines to
  5763.        reduce problems with tables in RTF:
  5764.  
  5765.        . Place the entire table definition before any paragraph properties,
  5766.          including \pard.
  5767.  
  5768.        . Make sure the number of cells in the RTF matches the number of cell
  5769.          definitions.
  5770.  
  5771.        . Some controls must be the same in all paragraphs in a row. In
  5772.          particular, all paragraphs in a row must have the same positioning
  5773.          controls, and all paragraphs in a row must have \intbl specified.
  5774.  
  5775.        . Do not use the \sbys control inside a table. \sbys is a holdover
  5776.          from Word for MS-DOS and early versions of Word for the Macintosh.
  5777.          Word for Windows and current versions of Word for the Macintosh
  5778.          translate \sbys as a table. Because Word for Windows and Word for
  5779.          the Macintosh do not support nested tables, these products will
  5780.          probably crash if you specify \sbys in a table.
  5781.  
  5782.        . Cell definitions starting before the left margin of the paper begins
  5783.          (that is, the parameter plus the left margin is negative) are always
  5784.          in error.
  5785.  
  5786.        . Even though nested tables are not explicitly defined in RTF, and
  5787.          Word for Windows and Word for the Macintosh do not support nested
  5788.          tables, you must still save table properties when changing
  5789.          destinations because tables can be nested inside other
  5790.          destinations--that is, you can have a table that contains a footnote
  5791.          or an annotation, and the footnote or annotation can contain another
  5792.  
  5793.  
  5794.  
  5795.  
  5796.                          Microsoft Product Support Services
  5797.  
  5798.  
  5799.                                                                      Page 95
  5800.  
  5801.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  5802.  
  5803.          table.
  5804.  
  5805.  
  5806.  
  5807.  
  5808.  
  5809.  
  5810.  
  5811.  
  5812.  
  5813.  
  5814.  
  5815.  
  5816.  
  5817.  
  5818.  
  5819.  
  5820.  
  5821.  
  5822.  
  5823.  
  5824.  
  5825.  
  5826.  
  5827.  
  5828.  
  5829.  
  5830.  
  5831.  
  5832.  
  5833.  
  5834.  
  5835.  
  5836.  
  5837.  
  5838.  
  5839.  
  5840.  
  5841.  
  5842.  
  5843.  
  5844.  
  5845.  
  5846.  
  5847.  
  5848.  
  5849.  
  5850.  
  5851.  
  5852.  
  5853.  
  5854.  
  5855.  
  5856.  
  5857.  
  5858.  
  5859.                          Microsoft Product Support Services
  5860.  
  5861.  
  5862.                                                                      Page 96
  5863.  
  5864.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  5865.  
  5866.        Appendix A-1: Listings
  5867.  
  5868.        RTFDECL.H
  5869.  
  5870.           // RTF parser declarations
  5871.  
  5872.           int ecRtfParse(FILE *fp);
  5873.           int ecPushRtfState(void);
  5874.           int ecPopRtfState(void);
  5875.           int ecParseRtfKeyword(FILE *fp);
  5876.           int ecParseChar(int c);
  5877.           int ecTranslateKeyword(char *szKeyword, int param, bool fParam);
  5878.           int ecPrintChar(int ch);
  5879.           int ecEndGroupAction(RDS rds);
  5880.           int ecApplyPropChange(IPROP iprop, int val);
  5881.           int ecChangeDest(IDEST idest);
  5882.           int ecParseSpecialKeyword(IPFN ipfn);
  5883.           int ecParseSpecialProperty(IPROP iprop, int val);
  5884.           int ecParseHexByte(void);
  5885.  
  5886.           // RTF variable declarations
  5887.  
  5888.           extern int cGroup;
  5889.           extern RDS rds;
  5890.           extern RIS ris;
  5891.  
  5892.           extern CHP chp;
  5893.           extern PAP pap;
  5894.           extern SEP sep;
  5895.           extern DOP dop;
  5896.  
  5897.           extern SAVE *psave;
  5898.           extern long cbBin;
  5899.           extern long lParam;
  5900.           extern bool fSkipDestIfUnk;
  5901.           extern FILE *fpIn;
  5902.  
  5903.           // RTF parser error codes
  5904.  
  5905.           #define ecOK 0                      // Everything's fine!
  5906.           #define ecStackUnderflow    1       // Unmatched '}'
  5907.           #define ecStackOverflow     2       // Too many '{' -- memory
  5908.           exhausted
  5909.           #define ecUnmatchedBrace    3       // RTF ended during an open
  5910.           group.
  5911.           #define ecInvalidHex        4       // invalid hex character found
  5912.           in data
  5913.           #define ecBadTable          5       // RTF table (sym or prop)
  5914.           invalid
  5915.           #define ecAssertion         6       // Assertion failure
  5916.           #define ecEndOfFile         7       // End of file reached while
  5917.           reading RTF
  5918.  
  5919.  
  5920.  
  5921.  
  5922.                          Microsoft Product Support Services
  5923.  
  5924.  
  5925.                                                                      Page 97
  5926.  
  5927.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  5928.  
  5929.        RTFTYPE.H
  5930.  
  5931.           typedef char bool;
  5932.           #define fTrue 1
  5933.           #define fFalse 0
  5934.  
  5935.           typedef struct char_prop
  5936.           {
  5937.               char fBold;
  5938.               char fUnderline;
  5939.               char fItalic;
  5940.           } CHP;                  // CHaracter Properties
  5941.  
  5942.           typedef enum {justL, justR, justC, justF } JUST;
  5943.           typedef struct para_prop
  5944.           {
  5945.               int xaLeft;                 // left indent in twips
  5946.               int xaRight;                // right indent in twips
  5947.               int xaFirst;                // first line indent in twips
  5948.               JUST just;                  // justification
  5949.           } PAP;                  // PAragraph Properties
  5950.  
  5951.           typedef enum {sbkNon, sbkCol, sbkEvn, sbkOdd, sbkPg} SBK;
  5952.           typedef enum {pgDec, pgURom, pgLRom, pgULtr, pgLLtr} PGN;
  5953.           typedef struct sect_prop
  5954.           {
  5955.               int cCols;                  // number of columns
  5956.               SBK sbk;                    // section break type
  5957.               int xaPgn;                  // x position of page number in
  5958.           twips
  5959.               int yaPgn;                  // y position of page number in
  5960.           twips
  5961.               PGN pgnFormat;              // how the page number is formatted
  5962.           } SEP;                  // SEction Properties
  5963.  
  5964.           typedef struct doc_prop
  5965.           {
  5966.               int xaPage;                 // page width in twips
  5967.               int yaPage;                 // page height in twips
  5968.               int xaLeft;                 // left margin in twips
  5969.               int yaTop;                  // top margin in twips
  5970.               int xaRight;                // right margin in twips
  5971.               int yaBottom;               // bottom margin in twips
  5972.               int pgnStart;               // starting page number in twips
  5973.               char fFacingp;              // facing pages enabled?
  5974.               char fLandscape;            // landscape or portrait??
  5975.           } DOP;                  // DOcument Properties
  5976.  
  5977.           typedef enum { rdsNorm, rdsSkip } RDS;              // Rtf
  5978.           Destination State
  5979.           typedef enum { risNorm, risBin, risHex } RIS;       // Rtf Internal
  5980.           State
  5981.  
  5982.  
  5983.  
  5984.  
  5985.                          Microsoft Product Support Services
  5986.  
  5987.  
  5988.                                                                      Page 98
  5989.  
  5990.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  5991.  
  5992.           typedef struct save             // property save structure
  5993.           {
  5994.               struct save *pNext;         // next save
  5995.               CHP chp;
  5996.               PAP pap;
  5997.               SEP sep;
  5998.               DOP dop;
  5999.               RDS rds;
  6000.               RIS ris;
  6001.           } SAVE;
  6002.  
  6003.           // What types of properties are there?
  6004.           typedef enum {ipropBold, ipropItalic, ipropUnderline, ipropLeftInd,
  6005.                         ipropRightInd, ipropFirstInd, ipropCols, ipropPgnX,
  6006.                         ipropPgnY, ipropXaPage, ipropYaPage, ipropXaLeft,
  6007.                         ipropXaRight, ipropYaTop, ipropYaBottom,
  6008.           ipropPgnStart,
  6009.                         ipropSbk, ipropPgnFormat, ipropFacingp,
  6010.           ipropLandscape,
  6011.                         ipropJust, ipropPard, ipropPlain, ipropSectd,
  6012.                         ipropMax } IPROP;
  6013.  
  6014.           typedef enum {actnSpec, actnByte, actnWord} ACTN;
  6015.           typedef enum {propChp, propPap, propSep, propDop} PROPTYPE;
  6016.  
  6017.           typedef struct propmod
  6018.           {
  6019.               ACTN actn;              // size of value
  6020.               PROPTYPE prop;          // structure containing value
  6021.               int  offset;            // offset of value from base of
  6022.           structure
  6023.           } PROP;
  6024.  
  6025.           typedef enum {ipfnBin, ipfnHex, ipfnSkipDest } IPFN;
  6026.           typedef enum {idestPict, idestSkip } IDEST;
  6027.           typedef enum {kwdChar, kwdDest, kwdProp, kwdSpec} KWD;
  6028.  
  6029.           typedef struct symbol
  6030.           {
  6031.               char *szKeyword;        // RTF keyword
  6032.               int  dflt;              // default value to use
  6033.               bool fPassDflt;         // true to use default value from this
  6034.           table
  6035.               KWD  kwd;               // base action to take
  6036.               int  idx;               // index into property table if kwd ==
  6037.           kwdProp
  6038.                                       // index into destination table if kwd
  6039.           == kwdDest
  6040.                                       // character to print if kwd == kwdChar
  6041.           } SYM;
  6042.  
  6043.  
  6044.  
  6045.  
  6046.  
  6047.  
  6048.                          Microsoft Product Support Services
  6049.  
  6050.  
  6051.                                                                      Page 99
  6052.  
  6053.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  6054.  
  6055.        RTFREADR.C
  6056.  
  6057.           #include <stdio.h>
  6058.           #include <stdlib.h>
  6059.           #include <ctype.h>
  6060.           #include "rtftype.h"
  6061.           #include "rtfdecl.h"
  6062.  
  6063.           int cGroup;
  6064.           bool fSkipDestIfUnk;
  6065.           long cbBin;
  6066.           long lParam;
  6067.  
  6068.           RDS rds;
  6069.           RIS ris;
  6070.  
  6071.           CHP chp;
  6072.           PAP pap;
  6073.           SEP sep;
  6074.           DOP dop;
  6075.  
  6076.           SAVE *psave;
  6077.           FILE *fpIn;
  6078.  
  6079.           //
  6080.           // %%Function: main
  6081.           //
  6082.           // Main loop. Initialize and parse RTF.
  6083.           //
  6084.           main(int argc, char *argv[])
  6085.           {
  6086.               FILE *fp;
  6087.               int ec;
  6088.  
  6089.               fp = fpIn = fopen("test.rtf", "r");
  6090.               if (!fp)
  6091.               {
  6092.                   printf ("Can't open test file!\n");
  6093.                   return 1;
  6094.               }
  6095.               if ((ec = ecRtfParse(fp)) != ecOK)
  6096.                   printf("error %d parsing rtf\n", ec);
  6097.               else
  6098.                   printf("Parsed RTF file OK\n");
  6099.               fclose(fp);
  6100.               return 0;
  6101.           }
  6102.  
  6103.           //
  6104.           // %%Function: ecRtfParse
  6105.           //
  6106.           // Step 1:
  6107.           // Isolate RTF keywords and send them to ecParseRtfKeyword;
  6108.  
  6109.  
  6110.  
  6111.                          Microsoft Product Support Services
  6112.  
  6113.  
  6114.                                                                     Page 100
  6115.  
  6116.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  6117.  
  6118.           // Push and pop state at the start and end of RTF groups;
  6119.           // Send text to ecParseChar for further processing.
  6120.           //
  6121.  
  6122.           int
  6123.           ecRtfParse(FILE *fp)
  6124.           {
  6125.               int ch;
  6126.               int ec;
  6127.               int cNibble = 2;
  6128.               int b = 0;
  6129.               while ((ch = getc(fp)) != EOF)
  6130.               {
  6131.                   if (cGroup < 0)
  6132.                       return ecStackUnderflow;
  6133.                   if (ris == risBin)                      // if we're parsing
  6134.           binary data, handle it directly
  6135.                   {
  6136.                       if ((ec = ecParseChar(ch)) != ecOK)
  6137.                           return ec;
  6138.                   }
  6139.                   else
  6140.                   {
  6141.                       switch (ch)
  6142.                       {
  6143.                       case '{':
  6144.                           if ((ec = ecPushRtfState()) != ecOK)
  6145.                               return ec;
  6146.                           break;
  6147.                       case '}':
  6148.                           if ((ec = ecPopRtfState()) != ecOK)
  6149.                               return ec;
  6150.                           break;
  6151.                       case '\\':
  6152.                           if ((ec = ecParseRtfKeyword(fp)) != ecOK)
  6153.                               return ec;
  6154.                           break;
  6155.                       case 0x0d:
  6156.                       case 0x0a:          // cr and lf are noise
  6157.           characters...
  6158.                           break;
  6159.                       default:
  6160.                           if (ris == risNorm)
  6161.                           {
  6162.                               if ((ec = ecParseChar(ch)) != ecOK)
  6163.                                   return ec;
  6164.                           }
  6165.                           else
  6166.                           {               // parsing hex data
  6167.                               if (ris != risHex)
  6168.                                   return ecAssertion;
  6169.                               b = b << 4;
  6170.                               if (isdigit(ch))
  6171.  
  6172.  
  6173.  
  6174.                          Microsoft Product Support Services
  6175.  
  6176.  
  6177.                                                                     Page 101
  6178.  
  6179.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  6180.  
  6181.                                   b += (char) ch - '0';
  6182.                               else
  6183.                               {
  6184.                                   if (islower(ch))
  6185.                                   {
  6186.                                       if (ch < 'a' || ch > 'f')
  6187.                                           return ecInvalidHex;
  6188.                                       b += (char) ch - 'a';
  6189.                                   }
  6190.                                   else
  6191.                                   {
  6192.                                       if (ch < 'A' || ch > 'F')
  6193.                                           return ecInvalidHex;
  6194.                                       b += (char) ch - 'A';
  6195.                                   }
  6196.                               }
  6197.                               cNibble--;
  6198.                               if (!cNibble)
  6199.                               {
  6200.                                   if ((ec = ecParseChar(ch)) != ecOK)
  6201.                                       return ec;
  6202.                                   cNibble = 2;
  6203.                                   b = 0;
  6204.           ris = risNorm;
  6205.                               }
  6206.                           }                   // end else (ris != risNorm)
  6207.                           break;
  6208.                       }       // switch
  6209.                   }           // else (ris != risBin)
  6210.               }               // while
  6211.               if (cGroup < 0)
  6212.                   return ecStackUnderflow;
  6213.               if (cGroup > 0)
  6214.                   return ecUnmatchedBrace;
  6215.               return ecOK;
  6216.           }
  6217.  
  6218.           //
  6219.           // %%Function: ecPushRtfState
  6220.           //
  6221.           // Save relevant info on a linked list of SAVE structures.
  6222.           //
  6223.  
  6224.           int
  6225.           ecPushRtfState(void)
  6226.           {
  6227.               SAVE *psaveNew = malloc(sizeof(SAVE));
  6228.               if (!psaveNew)
  6229.                   return ecStackOverflow;
  6230.  
  6231.               psaveNew -> pNext = psave;
  6232.               psaveNew -> chp = chp;
  6233.               psaveNew -> pap = pap;
  6234.  
  6235.  
  6236.  
  6237.                          Microsoft Product Support Services
  6238.  
  6239.  
  6240.                                                                     Page 102
  6241.  
  6242.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  6243.  
  6244.               psaveNew -> sep = sep;
  6245.               psaveNew -> dop = dop;
  6246.               psaveNew -> rds = rds;
  6247.               psaveNew -> ris = ris;
  6248.               ris = risNorm;
  6249.               psave = psaveNew;
  6250.               cGroup++;
  6251.               return ecOK;
  6252.           }
  6253.  
  6254.           //
  6255.           // %%Function: ecPopRtfState
  6256.           //
  6257.           // If we're ending a destination (that is, the destination is
  6258.           changing),
  6259.           // call ecEndGroupAction.
  6260.           // Always restore relevant info from the top of the SAVE list.
  6261.           //
  6262.  
  6263.           int
  6264.           ecPopRtfState(void)
  6265.           {
  6266.               SAVE *psaveOld;
  6267.               int ec;
  6268.  
  6269.               if (!psave)
  6270.                   return ecStackUnderflow;
  6271.  
  6272.               if (rds != psave->rds)
  6273.               {
  6274.                   if ((ec = ecEndGroupAction(rds)) != ecOK)
  6275.                       return ec;
  6276.               }
  6277.               chp = psave->chp;
  6278.               pap = psave->pap;
  6279.               sep = psave->sep;
  6280.               dop = psave->dop;
  6281.               rds = psave->rds;
  6282.               ris = psave->ris;
  6283.  
  6284.               psaveOld = psave;
  6285.               psave = psave->pNext;
  6286.               cGroup--;
  6287.               free(psaveOld);
  6288.               return ecOK;
  6289.           }
  6290.  
  6291.           //
  6292.           // %%Function: ecParseRtfKeyword
  6293.           //
  6294.           // Step 2:
  6295.           // get a control word (and its associated value) and
  6296.           // call ecTranslateKeyword to dispatch the control.
  6297.  
  6298.  
  6299.  
  6300.                          Microsoft Product Support Services
  6301.  
  6302.  
  6303.                                                                     Page 103
  6304.  
  6305.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  6306.  
  6307.           //
  6308.  
  6309.           int
  6310.           ecParseRtfKeyword(FILE *fp)
  6311.           {
  6312.               int ch;
  6313.               char fParam = fFalse;
  6314.               char fNeg = fFalse;
  6315.               int param = 0;
  6316.               char *pch;
  6317.               char szKeyword[30];
  6318.               char szParameter[20];
  6319.  
  6320.               szKeyword[0] = '\0';
  6321.               szParameter[0] = '\0';
  6322.               if ((ch = getc(fp)) == EOF)
  6323.                   return ecEndOfFile;
  6324.               if (!isalpha(ch))           // a control symbol; no delimiter.
  6325.               {
  6326.                   szKeyword[0] = (char) ch;
  6327.                   szKeyword[1] = '\0';
  6328.                   return ecTranslateKeyword(szKeyword, 0, fParam);
  6329.               }
  6330.               for (pch = szKeyword; isalpha(ch); ch = getc(fp))
  6331.                   *pch++ = (char) ch;
  6332.               *pch = '\0';
  6333.               if (ch == '-')
  6334.               {
  6335.                   fNeg  = fTrue;
  6336.                   if ((ch = getc(fp)) == EOF)
  6337.                       return ecEndOfFile;
  6338.               }
  6339.               if (isdigit(ch))
  6340.               {
  6341.                   fParam = fTrue;         // a digit after the control means
  6342.           we have a parameter
  6343.                   for (pch = szParameter; isdigit(ch); ch = getc(fp))
  6344.                       *pch++ = (char) ch;
  6345.                   *pch = '\0';
  6346.                   param = atoi(szParameter);
  6347.                   if (fNeg)
  6348.                       param = -param;
  6349.                   lParam = atol(szParameter);
  6350.                   if (fNeg)
  6351.                       param = -param;
  6352.               }
  6353.               if (ch != ' ')
  6354.                   ungetc(ch, fp);
  6355.               return ecTranslateKeyword(szKeyword, param, fParam);
  6356.           }
  6357.  
  6358.           //
  6359.           // %%Function: ecParseChar
  6360.  
  6361.  
  6362.  
  6363.                          Microsoft Product Support Services
  6364.  
  6365.  
  6366.                                                                     Page 104
  6367.  
  6368.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  6369.  
  6370.           //
  6371.           // Route the character to the appropriate destination stream.
  6372.           //
  6373.  
  6374.           int
  6375.           ecParseChar(int ch)
  6376.           {
  6377.               if (ris == risBin && --cbBin <= 0)
  6378.                   ris = risNorm;
  6379.               switch (rds)
  6380.               {
  6381.               case rdsSkip:
  6382.                   // Toss this character.
  6383.                   return ecOK;
  6384.               case rdsNorm:
  6385.                   // Output a character. Properties are valid at this point.
  6386.                   return ecPrintChar(ch);
  6387.               default:
  6388.               // handle other destinations....
  6389.                   return ecOK;
  6390.               }
  6391.           }
  6392.  
  6393.           //
  6394.           // %%Function: ecPrintChar
  6395.           //
  6396.           // Send a character to the output file.
  6397.           //
  6398.  
  6399.           int
  6400.           ecPrintChar(int ch)
  6401.           {
  6402.               // unfortunately, we don't do a whole lot here as far as layout
  6403.           goes...
  6404.               putchar(ch);
  6405.               return ecOK;
  6406.           }
  6407.  
  6408.  
  6409.  
  6410.  
  6411.  
  6412.  
  6413.  
  6414.  
  6415.  
  6416.  
  6417.  
  6418.  
  6419.  
  6420.  
  6421.  
  6422.  
  6423.  
  6424.  
  6425.  
  6426.                          Microsoft Product Support Services
  6427.  
  6428.  
  6429.                                                                     Page 105
  6430.  
  6431.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  6432.  
  6433.        RTFACTN.C
  6434.  
  6435.           #include <stdio.h>
  6436.           #include <string.h>
  6437.           #include <stddef.h>
  6438.           #include <ctype.h>
  6439.           #include "rtftype.h"
  6440.           #include "rtfdecl.h"
  6441.  
  6442.           // RTF parser tables
  6443.  
  6444.           // Property descriptions
  6445.           PROP rgprop [ipropMax] = {
  6446.               actnByte,   propChp,    offsetof(CHP, fBold),       //
  6447.           ipropBold
  6448.               actnByte,   propChp,    offsetof(CHP, fItalic),     //
  6449.           ipropItalic
  6450.               actnByte,   propChp,    offsetof(CHP, fUnderline),  //
  6451.           ipropUnderline
  6452.               actnWord,   propPap,    offsetof(PAP, xaLeft),      //
  6453.           ipropLeftInd
  6454.               actnWord,   propPap,    offsetof(PAP, xaRight),     //
  6455.           ipropRightInd
  6456.               actnWord,   propPap,    offsetof(PAP, xaFirst),     //
  6457.           ipropFirstInd
  6458.               actnWord,   propSep,    offsetof(SEP, cCols),       //
  6459.           ipropCols
  6460.               actnWord,   propSep,    offsetof(SEP, xaPgn),       //
  6461.           ipropPgnX
  6462.               actnWord,   propSep,    offsetof(SEP, yaPgn),       //
  6463.           ipropPgnY
  6464.               actnWord,   propDop,    offsetof(DOP, xaPage),      //
  6465.           ipropXaPage
  6466.               actnWord,   propDop,    offsetof(DOP, yaPage),      //
  6467.           ipropYaPage
  6468.               actnWord,   propDop,    offsetof(DOP, xaLeft),      //
  6469.           ipropXaLeft
  6470.               actnWord,   propDop,    offsetof(DOP, xaRight),     //
  6471.           ipropXaRight
  6472.               actnWord,   propDop,    offsetof(DOP, yaTop),       //
  6473.           ipropYaTop
  6474.               actnWord,   propDop,    offsetof(DOP, yaBottom),    //
  6475.           ipropYaBottom
  6476.               actnWord,   propDop,    offsetof(DOP, pgnStart),    //
  6477.           ipropPgnStart
  6478.               actnByte,   propSep,    offsetof(SEP, sbk),         // ipropSbk
  6479.               actnByte,   propSep,    offsetof(SEP, pgnFormat),   //
  6480.           ipropPgnFormat
  6481.               actnByte,   propDop,    offsetof(DOP, fFacingp),    //
  6482.           ipropFacingp
  6483.               actnByte,   propDop,    offsetof(DOP, fLandscape),  //
  6484.           ipropLandscape
  6485.               actnByte,   propPap,    offsetof(PAP, just),        //
  6486.  
  6487.  
  6488.  
  6489.                          Microsoft Product Support Services
  6490.  
  6491.  
  6492.                                                                     Page 106
  6493.  
  6494.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  6495.  
  6496.           ipropJust
  6497.               actnSpec,   propPap,    0,                          //
  6498.           ipropPard
  6499.               actnSpec,   propChp,    0,                          //
  6500.           ipropPlain
  6501.               actnSpec,   propSep,    0,                          //
  6502.           ipropSectd
  6503.           };
  6504.  
  6505.           // Keyword descriptions
  6506.           SYM rgsymRtf[] = {
  6507.           //  keyword     dflt    fPassDflt   kwd         idx
  6508.               "b",        1,      fFalse,     kwdProp,    ipropBold,
  6509.               "u",        1,      fFalse,     kwdProp,    ipropUnderline,
  6510.               "i",        1,      fFalse,     kwdProp,    ipropItalic,
  6511.               "li",       0,      fFalse,     kwdProp,    ipropLeftInd,
  6512.               "ri",       0,      fFalse,     kwdProp,    ipropRightInd,
  6513.               "fi",       0,      fFalse,     kwdProp,    ipropFirstInd,
  6514.               "cols",     1,      fFalse,     kwdProp,    ipropCols,
  6515.               "sbknone",  sbkNon, fTrue,      kwdProp,    ipropSbk,
  6516.               "sbkcol",   sbkCol, fTrue,      kwdProp,    ipropSbk,
  6517.               "sbkeven",  sbkEvn, fTrue,      kwdProp,    ipropSbk,
  6518.               "sbkodd",   sbkOdd, fTrue,      kwdProp,    ipropSbk,
  6519.               "sbkpage",  sbkPg,  fTrue,      kwdProp,    ipropSbk,
  6520.               "pgnx",     0,      fFalse,     kwdProp,    ipropPgnX,
  6521.               "pgny",     0,      fFalse,     kwdProp,    ipropPgnY,
  6522.               "pgndec",   pgDec,  fTrue,      kwdProp,    ipropPgnFormat,
  6523.               "pgnucrm",  pgURom, fTrue,      kwdProp,    ipropPgnFormat,
  6524.               "pgnlcrm",  pgLRom, fTrue,      kwdProp,    ipropPgnFormat,
  6525.               "pgnucltr", pgULtr, fTrue,      kwdProp,    ipropPgnFormat,
  6526.               "pgnlcltr", pgLLtr, fTrue,      kwdProp,    ipropPgnFormat,
  6527.               "qc",       justC,  fTrue,      kwdProp,    ipropJust,
  6528.               "ql",       justL,  fTrue,      kwdProp,    ipropJust,
  6529.               "qr",       justR,  fTrue,      kwdProp,    ipropJust,
  6530.               "qj",       justF,  fTrue,      kwdProp,    ipropJust,
  6531.               "paperw",   12240,  fFalse,     kwdProp,    ipropXaPage,
  6532.               "paperh",   15480,  fFalse,     kwdProp,    ipropYaPage,
  6533.               "margl",    1800,   fFalse,     kwdProp,    ipropXaLeft,
  6534.               "margr",    1800,   fFalse,     kwdProp,    ipropXaRight,
  6535.               "margt",    1440,   fFalse,     kwdProp,    ipropYaTop,
  6536.               "margb",    1440,   fFalse,     kwdProp,    ipropYaBottom,
  6537.               "pgnstart", 1,      fTrue,      kwdProp,    ipropPgnStart,
  6538.               "facingp",  1,      fTrue,      kwdProp,    ipropFacingp,
  6539.               "landscape",1,      fTrue,      kwdProp,    ipropLandscape,
  6540.               "par",      0,      fFalse,     kwdChar,    0x0a,
  6541.               "\0x0a",    0,      fFalse,     kwdChar,    0x0a,
  6542.               "\0x0d",    0,      fFalse,     kwdChar,    0x0a,
  6543.               "tab",      0,      fFalse,     kwdChar,    0x09,
  6544.               "ldblquote",0,      fFalse,     kwdChar,    '"',
  6545.               "rdblquote",0,      fFalse,     kwdChar,    '"',
  6546.               "bin",      0,      fFalse,     kwdSpec,    ipfnBin,
  6547.               "*",        0,      fFalse,     kwdSpec,    ipfnSkipDest,
  6548.               "'",        0,      fFalse,     kwdSpec,    ipfnHex,
  6549.  
  6550.  
  6551.  
  6552.                          Microsoft Product Support Services
  6553.  
  6554.  
  6555.                                                                     Page 107
  6556.  
  6557.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  6558.  
  6559.               "author",   0,      fFalse,     kwdDest,    idestSkip,
  6560.               "buptim",   0,      fFalse,     kwdDest,    idestSkip,
  6561.               "colortbl", 0,      fFalse,     kwdDest,    idestSkip,
  6562.               "comment",  0,      fFalse,     kwdDest,    idestSkip,
  6563.               "creatim",  0,      fFalse,     kwdDest,    idestSkip,
  6564.               "doccomm",  0,      fFalse,     kwdDest,    idestSkip,
  6565.               "fonttbl",  0,      fFalse,     kwdDest,    idestSkip,
  6566.               "footer",   0,      fFalse,     kwdDest,    idestSkip,
  6567.               "footerf",  0,      fFalse,     kwdDest,    idestSkip,
  6568.               "footerl",  0,      fFalse,     kwdDest,    idestSkip,
  6569.               "footerr",  0,      fFalse,     kwdDest,    idestSkip,
  6570.               "footnote", 0,      fFalse,     kwdDest,    idestSkip,
  6571.               "ftncn",    0,      fFalse,     kwdDest,    idestSkip,
  6572.               "ftnsep",   0,      fFalse,     kwdDest,    idestSkip,
  6573.               "ftnsepc",  0,      fFalse,     kwdDest,    idestSkip,
  6574.               "header",   0,      fFalse,     kwdDest,    idestSkip,
  6575.               "headerf",  0,      fFalse,     kwdDest,    idestSkip,
  6576.               "headerl",  0,      fFalse,     kwdDest,    idestSkip,
  6577.               "headerr",  0,      fFalse,     kwdDest,    idestSkip,
  6578.               "info",     0,      fFalse,     kwdDest,    idestSkip,
  6579.               "keywords", 0,      fFalse,     kwdDest,    idestSkip,
  6580.               "operator", 0,      fFalse,     kwdDest,    idestSkip,
  6581.               "pict",     0,      fFalse,     kwdDest,    idestSkip,
  6582.               "printim",  0,      fFalse,     kwdDest,    idestSkip,
  6583.               "private1", 0,      fFalse,     kwdDest,    idestSkip,
  6584.               "revtim",   0,      fFalse,     kwdDest,    idestSkip,
  6585.               "rxe",      0,      fFalse,     kwdDest,    idestSkip,
  6586.               "stylesheet",   0,      fFalse,     kwdDest,    idestSkip,
  6587.               "subject",  0,      fFalse,     kwdDest,    idestSkip,
  6588.               "tc",       0,      fFalse,     kwdDest,    idestSkip,
  6589.               "title",    0,      fFalse,     kwdDest,    idestSkip,
  6590.               "txe",      0,      fFalse,     kwdDest,    idestSkip,
  6591.               "xe",       0,      fFalse,     kwdDest,    idestSkip,
  6592.               "{",        0,      fFalse,     kwdChar,    '{',
  6593.               "}",        0,      fFalse,     kwdChar,    '}',
  6594.               "\\",       0,      fFalse,     kwdChar,    '\\'
  6595.               };
  6596.           int isymMax = sizeof(rgsymRtf) / sizeof(SYM);
  6597.  
  6598.           //
  6599.           // %%Function: ecApplyPropChange
  6600.           //
  6601.           // Set the property identified by _iprop_ to the value _val_.
  6602.           //
  6603.           //
  6604.  
  6605.           int
  6606.           ecApplyPropChange(IPROP iprop, int val)
  6607.           {
  6608.               char *pb;
  6609.  
  6610.               if (rds == rdsSkip)                 // If we're skipping text,
  6611.                   return ecOK;                    // don't do anything.
  6612.  
  6613.  
  6614.  
  6615.                          Microsoft Product Support Services
  6616.  
  6617.  
  6618.                                                                     Page 108
  6619.  
  6620.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  6621.  
  6622.  
  6623.               switch (rgprop[iprop].prop)
  6624.               {
  6625.               case propDop:
  6626.                   pb = (char *)&dop;
  6627.                   break;
  6628.               case propSep:
  6629.                   pb = (char *)&sep;
  6630.                   break;
  6631.               case propPap:
  6632.                   pb = (char *)&pap;
  6633.                   break;
  6634.               case propChp:
  6635.                   pb = (char *)&chp;
  6636.                   break;
  6637.               default:
  6638.                   if (rgprop[iprop].actn != actnSpec)
  6639.                       return ecBadTable;
  6640.                   break;
  6641.               }
  6642.               switch (rgprop[iprop].actn)
  6643.               {
  6644.               case actnByte:
  6645.                   pb[rgprop[iprop].offset] = (unsigned char) val;
  6646.                   break;
  6647.               case actnWord:
  6648.                   (*(int *) (pb+rgprop[iprop].offset)) = val;
  6649.                   break;
  6650.               case actnSpec:
  6651.                   return ecParseSpecialProperty(iprop, val);
  6652.                   break;
  6653.               default:
  6654.                   return ecBadTable;
  6655.               }
  6656.               return ecOK;
  6657.           }
  6658.  
  6659.           //
  6660.           // %%Function: ecParseSpecialProperty
  6661.           //
  6662.           // Set a property that requires code to evaluate.
  6663.           //
  6664.  
  6665.           int
  6666.           ecParseSpecialProperty(IPROP iprop, int val)
  6667.           {
  6668.               switch (iprop)
  6669.               {
  6670.               case ipropPard:
  6671.                   memset(&pap, 0, sizeof(pap));
  6672.                   return ecOK;
  6673.               case ipropPlain:
  6674.                   memset(&chp, 0, sizeof(chp));
  6675.  
  6676.  
  6677.  
  6678.                          Microsoft Product Support Services
  6679.  
  6680.  
  6681.                                                                     Page 109
  6682.  
  6683.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  6684.  
  6685.                   return ecOK;
  6686.               case ipropSectd:
  6687.                   memset(&sep, 0, sizeof(sep));
  6688.                   return ecOK;
  6689.               default:
  6690.                   return ecBadTable;
  6691.               }
  6692.               return ecBadTable;
  6693.           }
  6694.  
  6695.           //
  6696.           // %%Function: ecTranslateKeyword.
  6697.           //
  6698.           // Step 3.
  6699.           // Search rgsymRtf for szKeyword and evaluate it appropriately.
  6700.           //
  6701.           // Inputs:
  6702.           // szKeyword:   The RTF control to evaluate.
  6703.           // param:       The parameter of the RTF control.
  6704.           // fParam:      fTrue if the control had a parameter; (that is, if
  6705.           param is valid)
  6706.           //              fFalse if it did not.
  6707.           //
  6708.  
  6709.           int
  6710.           ecTranslateKeyword(char *szKeyword, int param, bool fParam)
  6711.           {
  6712.               int isym;
  6713.  
  6714.               // search for szKeyword in rgsymRtf
  6715.  
  6716.               for (isym = 0; isym < isymMax; isym++)
  6717.                   if (strcmp(szKeyword, rgsymRtf[isym].szKeyword) == 0)
  6718.                       break;
  6719.               if (isym == isymMax)            // control word not found
  6720.               {
  6721.                   if (fSkipDestIfUnk)         // if this is a new destination
  6722.                       rds = rdsSkip;          // skip the destination
  6723.                                               // else just discard it
  6724.                   fSkipDestIfUnk = fFalse;
  6725.                   return ecOK;
  6726.               }
  6727.  
  6728.               // found it!  use kwd and idx to determine what to do with it.
  6729.  
  6730.               fSkipDestIfUnk = fFalse;
  6731.               switch (rgsymRtf[isym].kwd)
  6732.               {
  6733.               case kwdProp:
  6734.                   if (rgsymRtf[isym].fPassDflt || !fParam)
  6735.                       param = rgsymRtf[isym].dflt;
  6736.                   return ecApplyPropChange(rgsymRtf[isym].idx, param);
  6737.               case kwdChar:
  6738.  
  6739.  
  6740.  
  6741.                          Microsoft Product Support Services
  6742.  
  6743.  
  6744.                                                                     Page 110
  6745.  
  6746.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  6747.  
  6748.                   return ecParseChar(rgsymRtf[isym].idx);
  6749.               case kwdDest:
  6750.                   return ecChangeDest(rgsymRtf[isym].idx);
  6751.               case kwdSpec:
  6752.                   return ecParseSpecialKeyword(rgsymRtf[isym].idx);
  6753.               default:
  6754.                   return ecBadTable;
  6755.               }
  6756.               return ecBadTable;
  6757.           }
  6758.  
  6759.           //
  6760.           // %%Function: ecChangeDest
  6761.           //
  6762.           // Change to the destination specified by idest.
  6763.           // There's usually more to do here than this...
  6764.           //
  6765.  
  6766.           int
  6767.           ecChangeDest(IDEST idest)
  6768.           {
  6769.               if (rds == rdsSkip)             // if we're skipping text,
  6770.                   return ecOK;                // don't do anything
  6771.  
  6772.               switch (idest)
  6773.               {
  6774.               default:
  6775.                   rds = rdsSkip;              // when in doubt, skip it...
  6776.                   break;
  6777.               }
  6778.               return ecOK;
  6779.           }
  6780.  
  6781.           //
  6782.           // %%Function: ecEndGroupAction
  6783.           //
  6784.           // The destination specified by rds is coming to a close.
  6785.           // If there's any cleanup that needs to be done, do it now.
  6786.           //
  6787.  
  6788.           int
  6789.           ecEndGroupAction(RDS rds)
  6790.           {
  6791.               return ecOK;
  6792.           }
  6793.  
  6794.           //
  6795.           // %%Function: ecParseSpecialKeyword
  6796.           //
  6797.           // Evaluate an RTF control that needs special processing.
  6798.           //
  6799.  
  6800.           int
  6801.  
  6802.  
  6803.  
  6804.                          Microsoft Product Support Services
  6805.  
  6806.  
  6807.                                                                     Page 111
  6808.  
  6809.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  6810.  
  6811.           ecParseSpecialKeyword(IPFN ipfn)
  6812.           {
  6813.               if (rds == rdsSkip && ipfn != ipfnBin)  // if we're skipping,
  6814.           and it's not
  6815.                   return ecOK;                        // the \bin keyword,
  6816.           ignore it.
  6817.               switch (ipfn)
  6818.               {
  6819.               case ipfnBin:
  6820.                   ris = risBin;
  6821.                   cbBin = lParam;
  6822.                   break;
  6823.               case ipfnSkipDest:
  6824.                   fSkipDestIfUnk = fTrue;
  6825.                   break;
  6826.               case ipfnHex:
  6827.            ris = risHex;
  6828.            break;
  6829.               default:
  6830.                   return ecBadTable;
  6831.               }
  6832.               return ecOK;
  6833.           }
  6834.        MAKEFILE
  6835.  
  6836.           CFLAGS = /Zi /Od
  6837.  
  6838.           rtfreadr.exe: rtfactn.obj rtfreadr.obj
  6839.           link rtfreadr.obj rtfactn.obj,rtfreadr,rtfreadr,slibce/COD;
  6840.  
  6841.           rtfactn.obj: rtfactn.c rtfdecl.h rtftype.h
  6842.  
  6843.           rtfreadr.obj: rtfreadr.c rtfdecl.h rtftype.h
  6844.  
  6845.  
  6846.  
  6847.  
  6848.  
  6849.  
  6850.  
  6851.  
  6852.  
  6853.  
  6854.  
  6855.  
  6856.  
  6857.  
  6858.  
  6859.  
  6860.  
  6861.  
  6862.  
  6863.  
  6864.  
  6865.  
  6866.  
  6867.                          Microsoft Product Support Services
  6868.  
  6869.  
  6870.                                                                     Page 113
  6871.  
  6872.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  6873.  
  6874.        APPENDIX B: WORD 6J RICH TEXT FORMAT ADDENDUM
  6875.  
  6876.        This document contains the changes to the Rich Text Format (RTF)
  6877.        specification for the Japanese version of Word 6.0 (all platforms). In
  6878.        this document, Word 6J refers to the Japanese version of Word 6.0 and
  6879.        RTF-J refers to the RTF specification described below. This document
  6880.        also contains some information about the interpretation of RTF-J and
  6881.        some behaviors of Word 6J.
  6882.  
  6883.        This document is meant to be used in conjunction with the full RTF
  6884.        specification, assumes you have read that document, and does not
  6885.        contain the necessary information to implement an RTF reader or writer
  6886.        by itself. If you have any questions, please refer to the main
  6887.        specification first.
  6888.  
  6889.                             Appendix B Table of Contents
  6890.  
  6891.        RTF-J .............................................................113
  6892.        ESCAPED EXPRESSIONS ...............................................113
  6893.        CHARACTER SET .....................................................114
  6894.           Character Mapping ..............................................114
  6895.              Font Family .................................................115
  6896.                 ShiftJIS Font Without \cpg or \fcharset ..................115
  6897.                 Composite Fonts (Associated Fonts for International Runs) 115
  6898.                 New Control Words Created by Word 6J .....................117
  6899.  
  6900.        RTF-J
  6901.  
  6902.        There is a Japanese local RTF specification, called RTF-J, that is
  6903.        somewhat different from the standard RTF specification. Although Word
  6904.        6J does not write RTF-J, it can read RTF-J files. It retains the text
  6905.        strings in the file and disregards unknown keywords.
  6906.  
  6907.        ESCAPED EXPRESSIONS
  6908.  
  6909.        An escape expression (for example, \'hh, \\, or \{) is usable in all
  6910.        RTF control words.
  6911.  
  6912.        Writer:
  6913.  
  6914.        In general RTF should be written out with all characters above 0x80 in
  6915.        the escaped form, \'hh.
  6916.  
  6917.            Character code       Write out as
  6918.            -------------------  -----------------------
  6919.            0x00 <= ch < 0x20    Escaped (\'hh)
  6920.  
  6921.            0x20 <= ch < 0x80    Raw (non-escaped)
  6922.                                 character
  6923.  
  6924.            0x80 <= ch <= 0xFF   Escaped (\'hh)
  6925.  
  6926.        For compatibility there is an RTFParam option in the [Microsoft Word]
  6927.  
  6928.  
  6929.  
  6930.                          Microsoft Product Support Services
  6931.  
  6932.  
  6933.                                                                     Page 114
  6934.  
  6935.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  6936.  
  6937.        section of the WORD6.INI file (which is the same as the WINWORD6.INI
  6938.        file in the U.S. version) that determines whether raw 8-bit characters
  6939.        or escaped characters are used for the double-byte characters in
  6940.        \stylesheet, \fonttbl, \bkmkstart, and \bkmkend. This option is valid
  6941.        only when writing out the RTF; it does not affect RTF reading
  6942.        behavior.
  6943.  
  6944.          [Microsoft Word]
  6945.  
  6946.          RTFParam=7 (the default) uses an escaped expression when the
  6947.          character is above 0x80.
  6948.  
  6949.          RTFParam=8 uses raw 8-bit characters for \stylesheet, \fonttbl,
  6950.          \bkmkstart, and \bkmkend (does not escape even if trailing-byte was
  6951.          an RTF special character such as \, {, or }).
  6952.  
  6953.        Reader:
  6954.  
  6955.        When the RTF reader encounters raw characters in the leading-byte
  6956.        range of the double-byte character, it regards the next character as
  6957.        the trailing byte of the double-byte character and combines the two
  6958.        characters into one double-byte character.
  6959.  
  6960.            Leading byte  Trailing byte   Validity
  6961.            ------------  --------------  --------------------------
  6962.            Escaped       Raw (0x20 <= ch Valid (standard format for
  6963.                          <= 0x7f)        double-byte character)
  6964.  
  6965.            Escaped       Escaped (other) Valid (standard format for
  6966.                                          double-byte character)
  6967.  
  6968.            Raw           Raw             Valid (RTF-J format for
  6969.                                          double-byte character)
  6970.  
  6971.            Raw           Escaped         Invalid
  6972.  
  6973.        CHARACTER SET
  6974.  
  6975.        Word 6J specifies the character set in the font table using \fcharset.
  6976.        Word 6.0J interprets \cpg437 as \fcharset0 and \cpg932 as \fcharset128
  6977.        if it encounters these keywords when reading RTF. If both \fcharset
  6978.        and \cpg appear in the font table, \cpg is ignored.
  6979.  
  6980.        Character Mapping
  6981.  
  6982.        Word maps single-byte characters according to character set
  6983.        information (for example, Macintosh to ANSI) and leaves double-byte
  6984.        characters unmapped.
  6985.  
  6986.  
  6987.  
  6988.  
  6989.  
  6990.  
  6991.  
  6992.  
  6993.                          Microsoft Product Support Services
  6994.  
  6995.  
  6996.                                                                     Page 115
  6997.  
  6998.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  6999.  
  7000.        Font Family
  7001.  
  7002.        RTF-J keywords Definition and Word's interpretation
  7003.        -------------- ------------------------------------------------------
  7004.           \jis        RTF-J uses \jis as a keyword for character set. Word 6
  7005.                       interprets this as \ansi, which is the default
  7006.                       character set used if the character set is not defined
  7007.  
  7008.           \fjminchou  RTF-J uses \fjminchou and \fjgothic to specify font
  7009.           and         family. Word 6J interprets these as \fnil, which is th
  7010.           \fjgothic   default font family.
  7011.  
  7012.        ShiftJIS Font Without \cpg or \fcharset
  7013.  
  7014.        If \cpg or \fcharset keywords are not present, Word 6J uses the text
  7015.        metrics of the font before determining the character set of these
  7016.        fonts. If the font is unknown, Word 6J assumes it is SHIFTJIS_CHARSET.
  7017.  
  7018.        Composite Fonts (Associated Fonts for International Runs)
  7019.  
  7020.        Word 6J defines control words to specify composite fonts as associated
  7021.        character properties. These control words follow the rule of
  7022.        associated character properties and understand font designation (\af).
  7023.        All other <aprops> are ignored in Word 6J.
  7024.  
  7025.        <atext>        <losbrun> | <hisbrun> | <dbrun>
  7026.  
  7027.        <losbrun>      \hich \af & <aprops> \dbch \af & <aprops> \loch <ptext
  7028.  
  7029.        <hisbrun>      \loch \af & <aprops> \dbch \af & <aprops> \hich <ptext
  7030.  
  7031.        <dbrun>        \loch \af & <aprops> \hich \af & <aprops> \dbch <ptext
  7032.  
  7033.        Control word   Definition
  7034.        -------------- -----------------------------------------------------
  7035.           \loch       Specifies a run of the characters in the low-ANSI
  7036.                       (0x00-0x7F) area.
  7037.  
  7038.           \hich       For the characters in the high-ANSI (0x80--0xFF) area.
  7039.  
  7040.           \dbch       Specifies a run of the double-byte characters.
  7041.  
  7042.        Word 6J writes out associated character properties in the styles. In
  7043.        the style sheet, the <dbrun> definition should be used for
  7044.        compatibility with applications that have transparent readers.
  7045.  
  7046.            {\stylesheet{\loch\af5\hich\af5\dbch\f27\fs20\snext0 Normal;}}
  7047.  
  7048.        If the composite font definition matches the style, only the control
  7049.        word (\loch, \hich, or \dbch) will be used to distinguish the type of
  7050.        run, along with the font information for transparent readers.
  7051.  
  7052.           {\fonttbl{\f5\fswiss\fcharset0\fprq2
  7053.  
  7054.  
  7055.  
  7056.                          Microsoft Product Support Services
  7057.  
  7058.  
  7059.                                                                     Page 116
  7060.  
  7061.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  7062.  
  7063.           Arial;}{\f27\froman\fcharset128\fprq1 Mincho;}}
  7064.           {\stylesheet{\loch\af5\hich\af5\dbch\f27\fs20\snext0 Normal;}}
  7065.           \pard\plain
  7066.           {\dbch\f27\fs20 \'82\'b1\'82\'ea\'82\'cd}
  7067.           {\loch\f5 Test }
  7068.           {\dbch\f27\'82\'c5\'82\'b7\'81B}
  7069.           \par}
  7070.        If one or all of \loch, \hich, and \dbch are missing from the style
  7071.        sheet definition (or the character set doesn't match), Word 6J will
  7072.        apply appropriate fonts to each character run in the style using the
  7073.        bulleted rules below.
  7074.  
  7075.        Control word   Font that Word 6J will apply
  7076.  
  7077.        -------------- -----------------------------------------------------
  7078.  
  7079.           \loch       Same font as \f.
  7080.  
  7081.           \hich       Any font whose character set is ANSI_CHARSET.
  7082.  
  7083.           \dbch       Any font whose character set is SHIFTJIS_CHARSET.
  7084.  
  7085.        If the composite font control words are missing from the character
  7086.        run, Word 6J will interpret all characters below 0x80 as a \loch run.
  7087.        Characters above or equal to 0x80 will be determined using the
  7088.        following rules:
  7089.  
  7090.        .  If the character is in the leading-byte range and the next
  7091.           character is in the trailing-byte range of a double-byte character,
  7092.           it will be treated as a \dbch run (one double-byte character). For
  7093.           example:
  7094.  
  7095.              \'99\'47a
  7096.  
  7097.        .  If the character is in the leading-byte range of a double-byte
  7098.           character but the next character is not in the trailing-byte range,
  7099.           it will be treated as a \hich run (two high-ANSI or low-ANSI
  7100.           characters). For example:
  7101.  
  7102.              \'99\'FFa_y
  7103.  
  7104.        .  If the character is in the leading-byte range of a double-byte
  7105.           character and is the last character in the run, it will be treated
  7106.           as a \hich run (one high-ANSI character). For example:
  7107.  
  7108.              \'99\para_
  7109.  
  7110.        .  If the character is not in the leading-byte range of a double-byte
  7111.           character, it will be treated as a \hich run (one high-ANSI
  7112.           character). For example:
  7113.  
  7114.              \'FFay
  7115.  
  7116.  
  7117.  
  7118.  
  7119.                          Microsoft Product Support Services
  7120.  
  7121.  
  7122.                                                                     Page 117
  7123.  
  7124.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  7125.  
  7126.        New Control Words Created by Word 6J
  7127.  
  7128.        ASSOCIATED CHARACTER PROPERTIES
  7129.  
  7130.        Control word   Description
  7131.        -------------- -----------------------------------------------------
  7132.           \loch       The text consists of single-byte low-ANSI (0x00-0x7F)
  7133.                       characters.
  7134.  
  7135.           \hich       The text consists of single-byte high-ANSI (0x80-0xFF)
  7136.                       characters.
  7137.  
  7138.           \dbch       The text consists of double-byte characters.
  7139.  
  7140.        Borders
  7141.  
  7142.           \brdrdash   Dashed border.
  7143.  
  7144.           \brdrdashd  Dash-dotted border.
  7145.  
  7146.           \brdrdashdd Dash-dot-dotted border.
  7147.  
  7148.        Character Properties
  7149.  
  7150.           \uldash     Dashed underline.
  7151.  
  7152.           \uldashd    Dash-dotted underline.
  7153.  
  7154.           \uldashdd   Dash-dot-dotted underline.
  7155.  
  7156.           \ulhair     Hairline underline.
  7157.  
  7158.           \ulth       Thick underline.
  7159.  
  7160.           \ulwave     Wave underline.
  7161.  
  7162.        Document Formatting Properties
  7163.  
  7164.           \horzdoc    Horizontal rendering.
  7165.  
  7166.           \vertdoc    Vertical rendering.
  7167.  
  7168.           \*\fchars   List of following kinsoku characters.
  7169.  
  7170.           \*\lchars   List of leading kinsoku characters.
  7171.  
  7172.           \jcompress  Compressing justification (default).
  7173.  
  7174.           \jexpand    Expanding justification.
  7175.  
  7176.           \gutterprl  Parallel gutter.
  7177.  
  7178.  
  7179.  
  7180.  
  7181.  
  7182.                          Microsoft Product Support Services
  7183.  
  7184.  
  7185.                                                                     Page 118
  7186.  
  7187.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  7188.  
  7189.        Control word   Description
  7190.        -------------- -----------------------------------------------------
  7191.           \dgsnap     Snap to grid.
  7192.  
  7193.           \dghspaceN  Grid horizontal spacing in twips (the default is 120).
  7194.  
  7195.           \dgvspaceN  Grid vertical spacing in twips (the default is 120).
  7196.  
  7197.           \dghoriginN Grid horizontal origin in twips (the default is 1701).
  7198.  
  7199.           \dgvoriginN Grid vertical origin in twips (the default is 1984).
  7200.  
  7201.           \dghshowN   Show Nth horizontal grid (the default is 3).
  7202.  
  7203.           \dgvshowN   Show Nth vertical grid (the default is 0).
  7204.  
  7205.        Bullets and Numbering
  7206.  
  7207.           \pndecd     Double-byte decimal numbering (\*arabic\*dbchar).
  7208.  
  7209.           \pndbnum    Kanji numbering without the digit character (\*dbnum1)
  7210.  
  7211.           \pnaiu      46 phonetic katakana characters in "aiueo" order
  7212.                       (\*aiueo).
  7213.  
  7214.           \pnaiud     46 phonetic double-byte katakana characters
  7215.                       (\*aiueo\*dbchar).
  7216.  
  7217.           \pniroha    46 phonetic katakana characters in "iroha" order
  7218.                       (\*iroha).
  7219.  
  7220.           \pnirohad   46 phonetic double-byte katakana characters
  7221.                       (\*iroha\*dbchar).
  7222.  
  7223.           \pncnum     20 numbered list in circle (\*circlenum).
  7224.  
  7225.           \pnuldash   Dashed underline.
  7226.  
  7227.           \pnuldashd  Dash-dotted underline.
  7228.  
  7229.           \pnuldashdd Dash-dot-dotted underline.
  7230.  
  7231.           \pnulhair   Hairline underline.
  7232.  
  7233.           \pnulth     Thick underline.
  7234.  
  7235.           \pnulwave   Wave underline.
  7236.  
  7237.        Drawing Objects
  7238.  
  7239.           \dptxlrtb   Text box flows from left to right and top to bottom
  7240.                       (default).
  7241.  
  7242.  
  7243.  
  7244.  
  7245.                          Microsoft Product Support Services
  7246.  
  7247.  
  7248.                                                                     Page 119
  7249.  
  7250.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  7251.  
  7252.        Control word   Description
  7253.        -------------- -----------------------------------------------------
  7254.           \dptxtbrl   Text box flows from right to left and top to bottom.
  7255.  
  7256.           \dptxbtlr   Text box flows from left to right and bottom to top.
  7257.  
  7258.           \dptxlrtbv  Text box flows from left to right and top to bottom,
  7259.                       vertically.
  7260.  
  7261.           \dptxtbrlv  Text box flows from top to bottom and right to left,
  7262.                       vertically.
  7263.  
  7264.        Index Entries
  7265.  
  7266.           \*\pxe      "Yomi" (pronunciation) for index entry.
  7267.  
  7268.        Paragraph Properties
  7269.  
  7270.           \nocwrap    No character wrapping.
  7271.  
  7272.           \nowwrap    No word wrapping.
  7273.  
  7274.           \qd         Distributed.
  7275.  
  7276.           \nooverflow No overflow period and comma.
  7277.  
  7278.           \aspalpha   Auto spacing between DBC and English.
  7279.  
  7280.           \aspnum     Auto spacing between DBC and numbers.
  7281.  
  7282.           \fahang     Font alignment R Hanging.
  7283.  
  7284.           \facenter   Font alignment R Center.
  7285.  
  7286.           \faroman    Font alignment R Roman (default).
  7287.  
  7288.           \favar      Font alignment R Upholding variable.
  7289.  
  7290.           \fafixed    Font alignment R Upholding fixed.
  7291.  
  7292.        Section Formatting Properties
  7293.  
  7294.           \horzsect   Horizontal rendering.
  7295.  
  7296.           \vertsect   Vertical rendering.
  7297.  
  7298.           \pgndecd    Double-byte decimal numbering.
  7299.  
  7300.           \pgndbnum   Kanji numbering without the digit character.
  7301.  
  7302.           \pgndbnumd  Kanji numbering with the digit character.
  7303.  
  7304.  
  7305.  
  7306.  
  7307.  
  7308.                          Microsoft Product Support Services
  7309.  
  7310.  
  7311.                                                                     Page 120
  7312.  
  7313.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  7314.  
  7315.        Control word   Description
  7316.        -------------- -----------------------------------------------------
  7317.        Special Characters
  7318.  
  7319.           \zwbo       Zero-width break opportunity. Used to insert break
  7320.                       opportunity between two characters.
  7321.  
  7322.           \zwnbo      Zero-width nonbreak opportunity. Used to remove break
  7323.                       opportunity between two characters.
  7324.  
  7325.           \qmspace    One-quarter em space.
  7326.  
  7327.        Tabs
  7328.  
  7329.           \tlmdot     Leader middle dots.
  7330.  
  7331.  
  7332.  
  7333.  
  7334.  
  7335.  
  7336.  
  7337.  
  7338.  
  7339.  
  7340.  
  7341.  
  7342.  
  7343.  
  7344.  
  7345.  
  7346.  
  7347.  
  7348.  
  7349.  
  7350.  
  7351.  
  7352.  
  7353.  
  7354.  
  7355.  
  7356.  
  7357.  
  7358.  
  7359.  
  7360.  
  7361.  
  7362.  
  7363.  
  7364.  
  7365.  
  7366.  
  7367.  
  7368.  
  7369.  
  7370.  
  7371.                          Microsoft Product Support Services
  7372.  
  7373.  
  7374.                                                                     Page 121
  7375.  
  7376.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  7377.  
  7378.        APPENDIX C: INDEX OF RTF CONTROL WORDS
  7379.  
  7380.        The following table contains a list of each RTF control word, the name
  7381.        of the section where it may be found, and a brief description of the
  7382.        type of control word. The types are described in the following table.
  7383.  
  7384.           Type         Description
  7385.           -----------  -----------------------------------------------------
  7386.           Flag         The control word ignores any parameter.
  7387.  
  7388.           Destination  This control word starts a group or destination. It
  7389.                        ignores any parameter.
  7390.  
  7391.           Symbol       This control word represents a special character.
  7392.  
  7393.           Toggle       This control word distinguishes between the ON and OFF
  7394.                        states for the given property. The control word with
  7395.                        no parameter or a nonzero parameter is used to turn on
  7396.                        the property, while the control word with a zero
  7397.                        parameter is used to turn it off.
  7398.  
  7399.           Value        This control word requires a parameter.
  7400.  
  7401.           Note: In the following comprehensive table, the names of all
  7402.           control words that are new to Microsoft Word version 6.0 are
  7403.           followed by an asterisk (*).
  7404.  
  7405.            Control word      Described in section            Type
  7406.            ---------------   ------------------------------  ---------------
  7407.            \'                Special Characters              Symbol
  7408.            \*                Special Characters              Symbol
  7409.            \-                Special Characters              Symbol
  7410.            \:                Special Characters              Symbol
  7411.            \\                Special Characters              Symbol
  7412.            \_                Special Characters              Symbol
  7413.            \{                Special Characters              Symbol
  7414.            \|                Special Characters              Symbol
  7415.            \}                Special Characters              Symbol
  7416.            \~                Special Characters              Symbol
  7417.            \ab               Associated Character            Toggle
  7418.                              Properties
  7419.            \absh             Positioned Objects and Frames   Value
  7420.            \absw             Positioned Objects and Frames   Value
  7421.            \acaps            Associated Character            Toggle
  7422.                              Properties
  7423.            \acf              Associated Character            Value
  7424.                              Properties
  7425.            \additive *       Style Sheet                     Flag
  7426.            \adn              Associated Character            Value
  7427.                              Properties
  7428.            \aenddoc *        Document Formatting Properties  Flag
  7429.            \aendnotes *      Document Formatting Properties  Flag
  7430.  
  7431.  
  7432.  
  7433.  
  7434.                          Microsoft Product Support Services
  7435.  
  7436.  
  7437.                                                                     Page 122
  7438.  
  7439.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  7440.  
  7441.            Control word      Described in section            Type
  7442.            ---------------   ------------------------------  ---------------
  7443.            \aexpnd           Associated Character            Value
  7444.                              Properties
  7445.            \af               Associated Character            Value
  7446.                              Properties
  7447.            \afs              Associated Character            Value
  7448.                              Properties
  7449.            \aftnbj *         Document Formatting Properties  Flag
  7450.            \aftncn *         Document Formatting Properties  Destination
  7451.            \aftnnalc *       Document Formatting Properties  Flag
  7452.            \aftnnar *        Document Formatting Properties  Flag
  7453.            \aftnnauc *       Document Formatting Properties  Flag
  7454.            \aftnnchi *       Document Formatting Properties  Flag
  7455.            \aftnnrlc *       Document Formatting Properties  Flag
  7456.            \aftnnruc *       Document Formatting Properties  Flag
  7457.            \aftnrestart *    Document Formatting Properties  Flag
  7458.            \aftnrstcont *    Document Formatting Properties  Flag
  7459.            \aftnsep *        Document Formatting Properties  Destination
  7460.            \aftnsepc *       Document Formatting Properties  Destination
  7461.            \aftnstart *      Document Formatting Properties  Value
  7462.            \aftntj *         Document Formatting Properties  Flag
  7463.            \ai               Associated Character            Toggle
  7464.                              Properties
  7465.            \alang            Associated Character            Value
  7466.                              Properties
  7467.            \allprot *        Document Formatting Properties  Flag
  7468.            \alt              Style Sheet                     Flag
  7469.            \annotation       Annotations                     Destination
  7470.            \annotprot *      Document Formatting Properties  Flag
  7471.            \ansi             Character Set                   Flag
  7472.            \aoutl            Associated Character            Toggle
  7473.                              Properties
  7474.            \ascaps           Associated Character            Toggle
  7475.                              Properties
  7476.            \ashad            Associated Character            Toggle
  7477.                              Properties
  7478.            \astrike          Associated Character            Toggle
  7479.                              Properties
  7480.            \atnauthor *      Annotations                     Destination
  7481.            \atnicn           Annotations                     Destination
  7482.            \atnid            Annotations                     Destination
  7483.            \atnref *         Annotations                     Destination
  7484.            \atntime          Annotations                     Destination
  7485.            \atrfend *        Annotations                     Destination
  7486.            \atrfstart *      Annotations                     Destination
  7487.            \aul              Associated Character            Toggle
  7488.                              Properties
  7489.            \auld             Associated Character            Toggle
  7490.                              Properties
  7491.            \auldb            Associated Character            Toggle
  7492.                              Properties
  7493.  
  7494.  
  7495.  
  7496.  
  7497.                          Microsoft Product Support Services
  7498.  
  7499.  
  7500.                                                                     Page 123
  7501.  
  7502.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  7503.  
  7504.            Control word      Described in section            Type
  7505.            ---------------   ------------------------------  ---------------
  7506.            \aulnone          Associated Character            Toggle
  7507.                              Properties
  7508.            \aulw             Associated Character            Toggle
  7509.                              Properties
  7510.            \aup              Associated Character            Value
  7511.                              Properties
  7512.            \author           Information Group               Destination
  7513.            \b                Character Formatting            Toggle
  7514.                              Properties
  7515.            \bgbdiag          Paragraph Shading               Flag
  7516.            \bgcross          Paragraph Shading               Flag
  7517.            \bgdcross         Paragraph Shading               Flag
  7518.            \bgdkbdiag        Paragraph Shading               Flag
  7519.            \bgdkcross        Paragraph Shading               Flag
  7520.            \bgdkdcross       Paragraph Shading               Flag
  7521.            \bgdkfdiag        Paragraph Shading               Flag
  7522.            \bgdkhoriz        Paragraph Shading               Flag
  7523.            \bgdkvert         Paragraph Shading               Flag
  7524.            \bgfdiag          Paragraph Shading               Flag
  7525.            \bghoriz          Paragraph Shading               Flag
  7526.            \bgvert           Paragraph Shading               Flag
  7527.            \bin              Pictures                        Value
  7528.            \binfsxn          Section Formatting Properties   Value
  7529.            \binsxn           Section Formatting Properties   Value
  7530.            \bkmkcolf         Bookmarks                       Value
  7531.            \bkmkcoll         Bookmarks                       Value
  7532.            \bkmkend          Bookmarks                       Destination
  7533.            \bkmkpub          Macintosh Edition Manager       Flag
  7534.                              Publisher Objects
  7535.            \bkmkstart        Bookmarks                       Destination
  7536.            \blue             Color Table                     Value
  7537.            \box              Paragraph Borders               Flag
  7538.            \brdrb            Paragraph Borders               Flag
  7539.            \brdrbar          Paragraph Borders               Flag
  7540.            \brdrbtw          Paragraph Borders               Flag
  7541.            \brdrcf           Paragraph Borders               Value
  7542.            \brdrdash *       Paragraph Borders               Flag
  7543.            \brdrdb           Paragraph Borders               Flag
  7544.            \brdrdot          Paragraph Borders               Flag
  7545.            \brdrhair         Paragraph Borders               Flag
  7546.            \brdrl            Paragraph Borders               Flag
  7547.            \brdrr            Paragraph Borders               Flag
  7548.            \brdrs            Paragraph Borders               Flag
  7549.            \brdrsh           Paragraph Borders               Flag
  7550.            \brdrt            Paragraph Borders               Flag
  7551.            \brdrth           Paragraph Borders               Flag
  7552.            \brdrw            Paragraph Borders               Value
  7553.            \brkfrm *         Document Formatting Properties  Flag
  7554.            \brsp             Paragraph Borders               Value
  7555.            \bullet           Special Characters              Symbol
  7556.            \buptim           Information Group               Destination
  7557.  
  7558.  
  7559.  
  7560.                          Microsoft Product Support Services
  7561.  
  7562.  
  7563.                                                                     Page 124
  7564.  
  7565.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  7566.  
  7567.            Control word      Described in section            Type
  7568.            ---------------   ------------------------------  ---------------
  7569.            \bxe              Index Entries                   Flag
  7570.            \caps             Character Formatting            Toggle
  7571.                              Properties
  7572.            \cb               Character Formatting            Value
  7573.                              Properties
  7574.            \cbpat            Paragraph Shading               Value
  7575.            \cchs *           Character Formatting            Value
  7576.                              Properties
  7577.            \cell             Special Characters              Symbol
  7578.            \cellx            Table Definitions               Value
  7579.            \cf               Character Formatting            Value
  7580.                              Properties
  7581.            \cfpat            Paragraph Shading               Value
  7582.            \chatn            Special Characters              Symbol
  7583.            \chdate           Special Characters              Symbol
  7584.            \chdpa            Special Characters              Symbol
  7585.            \chdpl            Special Characters              Symbol
  7586.            \chftn            Special Characters              Symbol
  7587.            \chftnsep         Special Characters              Symbol
  7588.            \chftnsepc        Special Characters              Symbol
  7589.            \chpgn            Special Characters              Symbol
  7590.            \chtime           Special Characters              Symbol
  7591.            \clbgbdiag        Table Definitions               Flag
  7592.            \clbgcross        Table Definitions               Flag
  7593.            \clbgdcross       Table Definitions               Flag
  7594.            \clbgdkbdiag      Table Definitions               Flag
  7595.            \clbgdkcross      Table Definitions               Flag
  7596.            \clbgdkdcross     Table Definitions               Flag
  7597.            \clbgdkfdiag      Table Definitions               Flag
  7598.            \clbgdkhor        Table Definitions               Flag
  7599.            \clbgdkvert       Table Definitions               Flag
  7600.            \clbgfdiag        Table Definitions               Flag
  7601.            \clbghoriz        Table Definitions               Flag
  7602.            \clbgvert         Table Definitions               Flag
  7603.            \clbrdrb          Table Definitions               Flag
  7604.            \clbrdrl          Table Definitions               Flag
  7605.            \clbrdrr          Table Definitions               Flag
  7606.            \clbrdrt          Table Definitions               Flag
  7607.            \clcbpat          Table Definitions               Value
  7608.            \clcfpat          Table Definitions               Value
  7609.            \clmgf            Table Definitions               Flag
  7610.            \clmrg            Table Definitions               Flag
  7611.            \clshdng          Table Definitions               Value
  7612.            \colno *          Section Formatting Properties   Value
  7613.            \colortbl         Color Table                     Destination
  7614.            \cols             Section Formatting Properties   Value
  7615.            \colsr *          Section Formatting Properties   Value
  7616.            \colsx            Section Formatting Properties   Value
  7617.            \column           Special Characters              Symbol
  7618.            \colw *           Section Formatting Properties   Value
  7619.            \comment          Information Group               Destination
  7620.  
  7621.  
  7622.  
  7623.                          Microsoft Product Support Services
  7624.  
  7625.  
  7626.                                                                     Page 125
  7627.  
  7628.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  7629.  
  7630.            Control word      Described in section            Type
  7631.            ---------------   ------------------------------  ---------------
  7632.            \cpg              Code Page Support               Value
  7633.            \creatim          Information Group               Destination
  7634.            \cs               Character Formatting            Value
  7635.                              Properties
  7636.            \ctrl             Style Sheet                     Flag
  7637.            \cvmme *          Document Formatting Properties  Flag
  7638.            \datafield *      Fields                          Destination
  7639.            \deff             Font Table                      Value
  7640.            \defformat        Document Formatting Properties  Flag
  7641.            \deflang          Document Formatting Properties  Value
  7642.            \deftab           Document Formatting Properties  Value
  7643.            \deleted          Character Formatting            Toggle
  7644.                              Properties
  7645.            \dfrmtxtx         Positioned Objects and Frames   Value
  7646.            \dfrmtxty         Positioned Objects and Frames   Value
  7647.            \dibitmap         Pictures                        Value
  7648.            \dn               Character Formatting            Value
  7649.                              Properties
  7650.            \do *             Drawing Objects                 Destination
  7651.            \dobxcolumn *     Drawing Objects                 Flag
  7652.            \dobxmargin *     Drawing Objects                 Flag
  7653.            \dobxpage *       Drawing Objects                 Flag
  7654.            \dobymargin *     Drawing Objects                 Flag
  7655.            \dobypage *       Drawing Objects                 Flag
  7656.            \dobypara *       Drawing Objects                 Flag
  7657.            \doccomm          Information Group               Destination
  7658.            \doctemp          Document Formatting Properties  Flag
  7659.            \dodhgt *         Drawing Objects                 Value
  7660.            \dolock *         Drawing Objects                 Flag
  7661.            \dpaendhol *      Drawing Objects                 Flag
  7662.            \dpaendl *        Drawing Objects                 Value
  7663.            \dpaendsol *      Drawing Objects                 Flag
  7664.            \dpaendw *        Drawing Objects                 Value
  7665.            \dparc *          Drawing Objects                 Flag
  7666.            \dparcflipx *     Drawing Objects                 Flag
  7667.            \dparcflipy *     Drawing Objects                 Flag
  7668.            \dpastarthol *    Drawing Objects                 Flag
  7669.            \dpastartl *      Drawing Objects                 Value
  7670.            \dpastartsol *    Drawing Objects                 Flag
  7671.            \dpastartw *      Drawing Objects                 Value
  7672.            \dpcallout *      Drawing Objects                 Flag
  7673.            \dpcoa *          Drawing Objects                 Value
  7674.            \dpcoaccent *     Drawing Objects                 Flag
  7675.            \dpcobestfit *    Drawing Objects                 Flag
  7676.            \dpcoborder *     Drawing Objects                 Flag
  7677.            \dpcodabs *       Drawing Objects                 Value
  7678.            \dpcodbottom *    Drawing Objects                 Flag
  7679.            \dpcodcenter *    Drawing Objects                 Flag
  7680.            \dpcodtop *       Drawing Objects                 Flag
  7681.            \dpcolength *     Drawing Objects                 Value
  7682.            \dpcominusx *     Drawing Objects                 Flag
  7683.  
  7684.  
  7685.  
  7686.                          Microsoft Product Support Services
  7687.  
  7688.  
  7689.                                                                     Page 126
  7690.  
  7691.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  7692.  
  7693.            Control word      Described in section            Type
  7694.            ---------------   ------------------------------  ---------------
  7695.            \dpcominusy *     Drawing Objects                 Flag
  7696.            \dpcooffset *     Drawing Objects                 Value
  7697.            \dpcosmarta *     Drawing Objects                 Flag
  7698.            \dpcotdouble *    Drawing Objects                 Flag
  7699.            \dpcotright *     Drawing Objects                 Flag
  7700.            \dpcotsingle *    Drawing Objects                 Flag
  7701.            \dpcottriple *    Drawing Objects                 Flag
  7702.            \dpcount *        Drawing Objects                 Value
  7703.            \dpellipse *      Drawing Objects                 Flag
  7704.            \dpendgroup *     Drawing Objects                 Flag
  7705.            \dpfillbgcb *     Drawing Objects                 Value
  7706.            \dpfillbgcg *     Drawing Objects                 Value
  7707.            \dpfillbgcr *     Drawing Objects                 Value
  7708.            \dpfillbggray *   Drawing Objects                 Value
  7709.            \dpfillbgpal *    Drawing Objects                 Flag
  7710.            \dpfillfgcb *     Drawing Objects                 Value
  7711.            \dpfillfgcg *     Drawing Objects                 Value
  7712.            \dpfillfgcr *     Drawing Objects                 Value
  7713.            \dpfillfggray *   Drawing Objects                 Value
  7714.            \dpfillfgpal *    Drawing Objects                 Flag
  7715.            \dpfillpat *      Drawing Objects                 Value
  7716.            \dpgroup *        Drawing Objects                 Flag
  7717.            \dpline *         Drawing Objects                 Flag
  7718.            \dplinecob *      Drawing Objects                 Value
  7719.            \dplinecog *      Drawing Objects                 Value
  7720.            \dplinecor *      Drawing Objects                 Value
  7721.            \dplinedado *     Drawing Objects                 Flag
  7722.            \dplinedadodo *   Drawing Objects                 Flag
  7723.            \dplinedash *     Drawing Objects                 Flag
  7724.            \dplinedot *      Drawing Objects                 Flag
  7725.            \dplinegray *     Drawing Objects                 Value
  7726.            \dplinehollow *   Drawing Objects                 Flag
  7727.            \dplinepal *      Drawing Objects                 Flag
  7728.            \dplinesolid *    Drawing Objects                 Flag
  7729.            \dplinew *        Drawing Objects                 Value
  7730.            \dppolycount *    Drawing Objects                 Value
  7731.            \dppolygon *      Drawing Objects                 Flag
  7732.            \dppolyline *     Drawing Objects                 Flag
  7733.            \dpptx *          Drawing Objects                 Value
  7734.            \dppty *          Drawing Objects                 Value
  7735.            \dprect *         Drawing Objects                 Flag
  7736.            \dproundr *       Drawing Objects                 Flag
  7737.            \dpshadow *       Drawing Objects                 Flag..
  7738.            \dpshadx *        Drawing Objects                 Value
  7739.            \dpshady *        Drawing Objects                 Value
  7740.            \dptxbx *         Drawing Objects                 Flag
  7741.            \dptxbxmar *      Drawing Objects                 Value
  7742.            \dptxbxtext *     Drawing Objects                 Destination
  7743.            \dpx *            Drawing Objects                 Value
  7744.            \dpxsize *        Drawing Objects                 Value
  7745.            \dpy *            Drawing Objects                 Value
  7746.  
  7747.  
  7748.  
  7749.                          Microsoft Product Support Services
  7750.  
  7751.  
  7752.                                                                     Page 127
  7753.  
  7754.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  7755.  
  7756.            Control word      Described in section            Type
  7757.            ---------------   ------------------------------  ---------------
  7758.            \dpysize *        Drawing Objects                 Value
  7759.            \dropcapli *      Positioned Objects and Frames   Value
  7760.            \dropcapt *       Positioned Objects and Frames   Value
  7761.            \ds               Section Formatting Properties   Value
  7762.            \dxfrtext         Positioned Objects and Frames   Value
  7763.            \dy               Information Group               Value
  7764.            \edmins           Information Group               Value
  7765.            \emdash           Special Characters              Symbol
  7766.            \emspace *        Special Characters              Symbol
  7767.            \endash           Special Characters              Symbol
  7768.            \enddoc           Document Formatting Properties  Flag
  7769.            \endnhere         Section Formatting Properties   Flag
  7770.            \endnotes         Document Formatting Properties  Flag
  7771.            \enspace *        Special Characters              Symbol
  7772.            \expnd            Character Formatting            Value
  7773.                              Properties
  7774.            \expndtw *        Character Formatting            Value
  7775.                              Properties
  7776.            \f                Character Formatting            Value
  7777.                              Properties
  7778.            \facingp          Document Formatting Properties  Flag
  7779.            \falt *           Font Table                      Destination
  7780.            \fbidi            Font Table                      Flag
  7781.            \fcharset *       Font Table                      Value
  7782.            \fdecor           Font Table                      Flag
  7783.            \fet *            Document Formatting Properties  Value
  7784.            \fi               Paragraph Formatting            Value
  7785.                              Properties
  7786.            \fid *            File Table                      Value
  7787.            \field            Fields                          Destination
  7788.            \file *           File Table                      Destination
  7789.            \filetbl *        File Table                      Destination
  7790.            \fldalt *         Document Formatting Properties  Flag
  7791.            \flddirty         Fields                          Flag
  7792.            \fldedit          Fields                          Flag
  7793.            \fldinst          Fields                          Destination
  7794.            \fldlock          Fields                          Flag
  7795.            \fldpriv          Fields                          Flag
  7796.            \fldrslt          Fields                          Destination
  7797.            \fmodern          Font Table                      Flag
  7798.            \fn               Style Sheet                     Value
  7799.            \fnetwork *       File Table                      Flag
  7800.            \fnil             Font Table                      Flag
  7801.            \fontemb          Font Table                      Destination
  7802.            \fontfile         Font Table                      Destination
  7803.            \fonttbl          Font Table                      Destination
  7804.            \footer           Headers and Footers             Destination
  7805.            \footerf          Headers and Footers             Destination
  7806.            \footerl          Headers and Footers             Destination
  7807.            \footerr          Headers and Footers             Destination
  7808.            \footery          Section Formatting Properties   Value
  7809.  
  7810.  
  7811.  
  7812.                          Microsoft Product Support Services
  7813.  
  7814.  
  7815.                                                                     Page 128
  7816.  
  7817.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  7818.  
  7819.            Control word      Described in section            Type
  7820.            ---------------   ------------------------------  ---------------
  7821.            \footnote         Footnotes                       Destination
  7822.            \formdisp *       Document Formatting Properties  Flag
  7823.            \formprot *       Document Formatting Properties  Flag
  7824.            \formshade *      Document Formatting Properties  Flag
  7825.            \fosnum *         File Table                      Value
  7826.            \fprq *           Font Table                      Value
  7827.            \fracwidth        Document Formatting Properties  Flag
  7828.            \frelative *      File Table                      Value
  7829.            \froman           Font Table                      Flag
  7830.            \fs               Character Formatting            Value
  7831.                              Properties
  7832.            \fscript          Font Table                      Flag
  7833.            \fswiss           Font Table                      Flag
  7834.            \ftech            Font Table                      Flag
  7835.            \ftnalt *         Document Formatting Properties  Flag
  7836.            \ftnbj            Document Formatting Properties  Flag
  7837.            \ftncn            Document Formatting Properties  Destination
  7838.            \ftnil            Font Table                      Flag
  7839.            \ftnnalc *        Document Formatting Properties  Flag
  7840.            \ftnnar *         Document Formatting Properties  Flag
  7841.            \ftnnauc *        Document Formatting Properties  Flag
  7842.            \ftnnchi *        Document Formatting Properties  Flag
  7843.            \ftnnrlc *        Document Formatting Properties  Flag
  7844.            \ftnnruc *        Document Formatting Properties  Flag
  7845.            \ftnrestart       Document Formatting Properties  Flag
  7846.            \ftnrstcont *     Document Formatting Properties  Flag
  7847.            \ftnrstpg *       Document Formatting Properties  Flag
  7848.            \ftnsep           Document Formatting Properties  Destination
  7849.            \ftnsepc          Document Formatting Properties  Destination
  7850.            \ftnstart         Document Formatting Properties  Value
  7851.            \ftntj            Document Formatting Properties  Flag
  7852.            \fttruetype       Font Table                      Flag
  7853.            \fvaliddos *      File Table                      Flag
  7854.            \fvalidhpfs *     File Table                      Flag
  7855.            \fvalidmac *      File Table                      Flag
  7856.            \fvalidntfs *     File Table                      Flag
  7857.            \green            Color Table                     Value
  7858.            \gutter           Document Formatting Properties  Value
  7859.            \guttersxn        Section Formatting Properties   Value
  7860.            \header           Headers and Footers             Destination
  7861.            \headerf          Headers and Footers             Destination
  7862.            \headerl          Headers and Footers             Destination
  7863.            \headerr          Headers and Footers             Destination
  7864.            \headery          Section Formatting Properties   Value
  7865.            \hr               Information Group               Value
  7866.            \hyphauto *       Document Formatting Properties  Toggle
  7867.            \hyphcaps *       Document Formatting Properties  Toggle
  7868.            \hyphconsec *     Document Formatting Properties  Value
  7869.            \hyphhotz         Document Formatting Properties  Value
  7870.            \hyphpar *        Paragraph Formatting            Toggle
  7871.                              Properties
  7872.  
  7873.  
  7874.  
  7875.                          Microsoft Product Support Services
  7876.  
  7877.  
  7878.                                                                     Page 129
  7879.  
  7880.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  7881.  
  7882.            Control word      Described in section            Type
  7883.            ---------------   ------------------------------  ---------------
  7884.            \i                Character Formatting            Toggle
  7885.                              Properties
  7886.            \id               Information Group               Value
  7887.            \info             Information Group               Destination
  7888.            \intbl            Paragraph Formatting            Flag
  7889.                              Properties
  7890.            \ixe              Index Entries                   Flag
  7891.            \keep             Paragraph Formatting            Flag
  7892.                              Properties
  7893.            \keepn            Paragraph Formatting            Flag
  7894.                              Properties
  7895.            \kerning *        Character Formatting            Value
  7896.                              Properties
  7897.            \keycode          Style Sheet                     Destination
  7898.            \keywords         Information Group               Destination
  7899.            \landscape        Document Formatting Properties  Flag
  7900.            \lang             Character Formatting            Value
  7901.                              Properties
  7902.            \ldblquote        Special Characters              Symbol
  7903.            \level            Paragraph Formatting            Value
  7904.                              Properties
  7905.            \li               Paragraph Formatting            Value
  7906.                              Properties
  7907.            \line             Special Characters              Symbol
  7908.            \linebetcol       Section Formatting Properties   Flag
  7909.            \linecont         Section Formatting Properties   Flag
  7910.            \linemod          Section Formatting Properties   Value
  7911.            \lineppage        Section Formatting Properties   Flag
  7912.            \linerestart      Section Formatting Properties   Flag
  7913.            \linestart        Document Formatting Properties  Value
  7914.            \linestarts       Section Formatting Properties   Value
  7915.            \linex            Section Formatting Properties   Value
  7916.            \linkself         Objects                         Flag
  7917.            \linkstyles *     Document Formatting Properties  Flag
  7918.            \lndscpsxn        Section Formatting Properties   Flag
  7919.            \lquote           Special Characters              Symbol
  7920.            \ltrch            Character Formatting            Flag
  7921.                              Properties
  7922.            \ltrdoc           Document Formatting Properties  Flag
  7923.            \ltrmark          Special Characters              Symbol
  7924.            \ltrpar           Paragraph Formatting            Flag
  7925.                              Properties
  7926.            \ltrrow           Table Definitions               Flag
  7927.            \ltrsect          Section Formatting Properties   Flag
  7928.            \mac              Character Set                   Flag
  7929.            \macpict          Pictures                        Flag
  7930.            \makebackup       Document Formatting Properties  Flag
  7931.            \margb            Document Formatting Properties  Value
  7932.            \margbsxn         Section Formatting Properties   Value
  7933.            \margl            Document Formatting Properties  Value
  7934.            \marglsxn         Section Formatting Properties   Value
  7935.  
  7936.  
  7937.  
  7938.                          Microsoft Product Support Services
  7939.  
  7940.  
  7941.                                                                     Page 130
  7942.  
  7943.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  7944.  
  7945.            Control word      Described in section            Type
  7946.            ---------------   ------------------------------  ---------------
  7947.            \margmirror       Document Formatting Properties  Flag
  7948.            \margr            Document Formatting Properties  Value
  7949.            \margrsxn         Section Formatting Properties   Value
  7950.            \margt            Document Formatting Properties  Value
  7951.            \margtsxn         Section Formatting Properties   Value
  7952.            \min              Information Group               Value
  7953.            \mo               Information Group               Value
  7954.            \nextfile         Document Formatting Properties  Destination
  7955.            \nocolbal *       Document Formatting Properties  Flag
  7956.            \noextrasprl *    Document Formatting Properties  Flag
  7957.            \nofchars         Information Group               Value
  7958.            \nofpages         Information Group               Value
  7959.            \nofwords         Information Group               Value
  7960.            \noline           Paragraph Formatting            Flag
  7961.                              Properties
  7962.            \nosupersub *     Character Formatting            Flag
  7963.                              Properties
  7964.            \notabind *       Document Formatting Properties  Flag
  7965.            \nowidctlpar *    Paragraph Formatting            Flag
  7966.                              Properties
  7967.            \nowrap           Positioned Objects and Frames   Flag
  7968.            \objalias         Objects                         Destination
  7969.            \objalign         Objects                         Value
  7970.            \objautlink       Objects                         Flag
  7971.            \objclass         Objects                         Destination
  7972.            \objcropb         Objects                         Value
  7973.            \objcropl         Objects                         Value
  7974.            \objcropr         Objects                         Value
  7975.            \objcropt         Objects                         Value
  7976.            \objdata          Objects                         Destination
  7977.            \object           Objects                         Destination
  7978.            \objemb           Objects                         Flag
  7979.            \objh             Objects                         Value
  7980.            \objicemb         Objects                         Flag
  7981.            \objlink          Objects                         Flag
  7982.            \objlock          Objects                         Flag
  7983.            \objname          Objects                         Destination
  7984.            \objpub           Objects                         Flag
  7985.            \objscalex        Objects                         Value
  7986.            \objscaley        Objects                         Value
  7987.            \objsect          Objects                         Destination
  7988.            \objsetsize       Objects                         Flag
  7989.            \objsub           Objects                         Flag
  7990.            \objtime          Objects                         Destination
  7991.            \objtransy        Objects                         Value
  7992.            \objupdate *      Objects                         Flag
  7993.            \objw             Objects                         Value
  7994.            \operator         Information Group               Destination
  7995.            \otblrul *        Document Formatting Properties  Flag
  7996.            \outl             Character Formatting            Toggle
  7997.                              Properties
  7998.  
  7999.  
  8000.  
  8001.                          Microsoft Product Support Services
  8002.  
  8003.  
  8004.                                                                     Page 131
  8005.  
  8006.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  8007.  
  8008.            Control word      Described in section            Type
  8009.            ---------------   ------------------------------  ---------------
  8010.            \page             Special Characters              Symbol
  8011.            \pagebb           Paragraph Formatting            Flag
  8012.                              Properties
  8013.            \paperh           Document Formatting Properties  Value
  8014.            \paperw           Document Formatting Properties  Value
  8015.            \par              Special Characters              Symbol
  8016.            \pard             Paragraph Formatting            Flag
  8017.                              Properties
  8018.            \pc               Character Set                   Flag
  8019.            \pca              Character Set                   Flag
  8020.            \pghsxn           Section Formatting Properties   Value
  8021.            \pgncont          Section Formatting Properties   Flag
  8022.            \pgndec           Section Formatting Properties   Flag
  8023.            \pgnhn *          Section Formatting Properties   Value
  8024.            \pgnhnsc *        Section Formatting Properties   Flag
  8025.            \pgnhnsh *        Section Formatting Properties   Flag
  8026.            \pgnhnsm *        Section Formatting Properties   Flag
  8027.            \pgnhnsn *        Section Formatting Properties   Flag
  8028.            \pgnhnsp *        Section Formatting Properties   Flag
  8029.            \pgnlcltr         Section Formatting Properties   Flag
  8030.            \pgnlcrm          Section Formatting Properties   Flag
  8031.            \pgnrestart       Section Formatting Properties   Flag
  8032.            \pgnstart         Document Formatting Properties  Value
  8033.            \pgnstarts        Section Formatting Properties   Value
  8034.            \pgnucltr         Section Formatting Properties   Flag
  8035.            \pgnucrm          Section Formatting Properties   Flag
  8036.            \pgnx             Section Formatting Properties   Value
  8037.            \pgny             Section Formatting Properties   Value
  8038.            \pgwsxn           Section Formatting Properties   Value
  8039.            \phcol            Positioned Objects and Frames   Flag
  8040.            \phmrg            Positioned Objects and Frames   Flag
  8041.            \phpg             Positioned Objects and Frames   Flag
  8042.            \picbmp *         Pictures                        Flag
  8043.            \picbpp *         Pictures                        Value
  8044.            \piccropb         Pictures                        Value
  8045.            \piccropl         Pictures                        Value
  8046.            \piccropr         Pictures                        Value
  8047.            \piccropt         Pictures                        Value
  8048.            \pich             Pictures                        Value
  8049.            \pichgoal         Pictures                        Value
  8050.            \picscaled        Pictures                        Flag
  8051.            \picscalex        Pictures                        Value
  8052.            \picscaley        Pictures                        Value
  8053.            \pict             Pictures                        Destination
  8054.            \picw             Pictures                        Value
  8055.            \picwgoal         Pictures                        Value
  8056.            \plain            Character Formatting            Flag
  8057.                              Properties
  8058.            \pmmetafile       Pictures                        Value
  8059.            \pn *             Bullets and Numbering           Destination
  8060.            \pnacross *       Bullets and Numbering           Flag
  8061.  
  8062.  
  8063.  
  8064.                          Microsoft Product Support Services
  8065.  
  8066.  
  8067.                                                                     Page 132
  8068.  
  8069.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  8070.  
  8071.            Control word      Described in section            Type
  8072.            ---------------   ------------------------------  ---------------
  8073.            \pnb *            Bullets and Numbering           Toggle
  8074.            \pncaps *         Bullets and Numbering           Toggle
  8075.            \pncard *         Bullets and Numbering           Flag
  8076.            \pncf *           Bullets and Numbering           Value
  8077.            \pndec *          Bullets and Numbering           Flag
  8078.            \pnf *            Bullets and Numbering           Value
  8079.            \pnfs *           Bullets and Numbering           Value
  8080.            \pnhang *         Bullets and Numbering           Flag
  8081.            \pni *            Bullets and Numbering           Toggle
  8082.            \pnindent *       Bullets and Numbering           Value
  8083.            \pnlcltr *        Bullets and Numbering           Flag
  8084.            \pnlcrm *         Bullets and Numbering           Flag
  8085.            \pnlvl *          Bullets and Numbering           Value
  8086.            \pnlvlblt *       Bullets and Numbering           Flag
  8087.            \pnlvlbody *      Bullets and Numbering           Flag
  8088.            \pnlvlcont *      Bullets and Numbering           Flag
  8089.            \pnnumonce *      Bullets and Numbering           Flag
  8090.            \pnord *          Bullets and Numbering           Flag
  8091.            \pnordt *         Bullets and Numbering           Flag
  8092.            \pnprev *         Bullets and Numbering           Flag
  8093.            \pnqc *           Bullets and Numbering           Flag
  8094.            \pnql *           Bullets and Numbering           Flag
  8095.            \pnqr *           Bullets and Numbering           Flag
  8096.            \pnrestart *      Bullets and Numbering           Flag
  8097.            \pnscaps *        Bullets and Numbering           Toggle
  8098.            \pnseclvl *       Bullets and Numbering           Destination
  8099.            \pnsp *           Bullets and Numbering           Value
  8100.            \pnstart *        Bullets and Numbering           Value
  8101.            \pnstrike *       Bullets and Numbering           Toggle
  8102.            \pntext *         Bullets and Numbering           Destination
  8103.            \pntxta *         Bullets and Numbering           Destination
  8104.            \pntxtb *         Bullets and Numbering           Destination
  8105.            \pnucltr *        Bullets and Numbering           Flag
  8106.            \pnucrm *         Bullets and Numbering           Flag
  8107.            \pnul *           Bullets and Numbering           Toggle
  8108.            \pnuld *          Bullets and Numbering           Flag
  8109.            \pnuldb *         Bullets and Numbering           Flag
  8110.            \pnulnone *       Bullets and Numbering           Flag
  8111.            \pnulw *          Bullets and Numbering           Flag
  8112.            \posnegx *        Positioned Objects and Frames   Value
  8113.            \posnegy *        Positioned Objects and Frames   Value
  8114.            \posx             Positioned Objects and Frames   Value
  8115.            \posxc            Positioned Objects and Frames   Flag
  8116.            \posxi            Positioned Objects and Frames   Flag
  8117.            \posxl            Positioned Objects and Frames   Flag
  8118.            \posxo            Positioned Objects and Frames   Flag
  8119.            \posxr            Positioned Objects and Frames   Flag
  8120.            \posy             Positioned Objects and Frames   Value
  8121.            \posyb            Positioned Objects and Frames   Flag
  8122.            \posyc            Positioned Objects and Frames   Flag
  8123.            \posyil           Positioned Objects and Frames   Flag
  8124.  
  8125.  
  8126.  
  8127.                          Microsoft Product Support Services
  8128.  
  8129.  
  8130.                                                                     Page 133
  8131.  
  8132.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  8133.  
  8134.            Control word      Described in section            Type
  8135.            ---------------   ------------------------------  ---------------
  8136.            \posyt            Positioned Objects and Frames   Flag
  8137.            \prcolbl *        Document Formatting Properties  Flag
  8138.            \printdata *      Document Formatting Properties  Flag
  8139.            \printim          Information Group               Destination
  8140.            \psover           Document Formatting Properties  Flag
  8141.            \psz *            Document Formatting Properties  Value
  8142.            \pubauto          Macintosh Edition Manager       Flag
  8143.                              Publisher Objects
  8144.            \pvmrg            Positioned Objects and Frames   Flag
  8145.            \pvpara           Positioned Objects and Frames   Flag
  8146.            \pvpg             Positioned Objects and Frames   Flag
  8147.            \qc               Paragraph Formatting            Flag
  8148.                              Properties
  8149.            \qj               Paragraph Formatting            Flag
  8150.                              Properties
  8151.            \ql               Paragraph Formatting            Flag
  8152.                              Properties
  8153.            \qr               Paragraph Formatting            Flag
  8154.                              Properties
  8155.            \rdblquote        Special Characters              Symbol
  8156.            \red              Color Table                     Value
  8157.            \result           Objects                         Destination
  8158.            \revauth *        Character Formatting            Value
  8159.                              Properties
  8160.            \revbar           Document Formatting Properties  Value
  8161.            \revdttm *        Character Formatting            Value
  8162.                              Properties
  8163.            \revised          Character Formatting            Toggle
  8164.                              Properties
  8165.            \revisions        Document Formatting Properties  Flag
  8166.            \revprop          Document Formatting Properties  Value
  8167.            \revprot *        Document Formatting Properties  Flag
  8168.            \revtbl *         Revision Marks                  Destination
  8169.            \revtim           Information Group               Destination
  8170.            \ri               Paragraph Formatting            Value
  8171.                              Properties
  8172.            \row              Special Characters              Symbol
  8173.            \rquote           Special Characters              Symbol
  8174.            \rsltbmp          Objects                         Flag
  8175.            \rsltmerge        Objects                         Flag
  8176.            \rsltpict         Objects                         Flag
  8177.            \rsltrtf          Objects                         Flag
  8178.            \rslttxt          Objects                         Flag
  8179.            \rtf              RTF Version                     Destination
  8180.            \rtlch            Character Formatting            Flag
  8181.                              Properties
  8182.            \rtldoc           Document Formatting Properties  Flag
  8183.            \rtlmark          Bidirectional Language Support  Symbol
  8184.                              and Special Characters
  8185.            \rtlpar           Paragraph Formatting            Flag
  8186.                              Properties
  8187.  
  8188.  
  8189.  
  8190.                          Microsoft Product Support Services
  8191.  
  8192.  
  8193.                                                                     Page 134
  8194.  
  8195.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  8196.  
  8197.            Control word      Described in section            Type
  8198.            ---------------   ------------------------------  ---------------
  8199.            \rtlrow           Table Definitions               Flag
  8200.            \rtlsect          Section Formatting Properties   Flag
  8201.            \rxe              Index Entries                   Destination
  8202.            \s                Paragraph Formatting            Value
  8203.                              Properties
  8204.            \sa               Paragraph Formatting            Value
  8205.                              Properties
  8206.            \sb               Paragraph Formatting            Value
  8207.                              Properties
  8208.            \sbasedon         Style Sheet                     Value
  8209.            \sbkcol           Section Formatting Properties   Flag
  8210.            \sbkeven          Section Formatting Properties   Flag
  8211.            \sbknone          Section Formatting Properties   Flag
  8212.            \sbkodd           Section Formatting Properties   Flag
  8213.            \sbkpage          Section Formatting Properties   Flag
  8214.            \sbys             Paragraph Formatting            Flag
  8215.                              Properties
  8216.            \scaps            Character Formatting            Toggle
  8217.                              Properties
  8218.            \sec              Information Group               Value
  8219.            \sect             Special Characters              Symbol
  8220.            \sectd            Section Formatting Properties   Flag
  8221.            \sectnum          Special Characters              Symbol
  8222.            \sectunlocked *   Section Formatting Properties   Flag
  8223.            \shad             Character Formatting            Toggle
  8224.                              Properties
  8225.            \shading          Paragraph Shading               Value
  8226.            \shift            Style Sheet                     Flag
  8227.            \sl               Paragraph Formatting            Value
  8228.                              Properties
  8229.            \slmult *         Paragraph Formatting            Value
  8230.                              Properties
  8231.            \snext            Style Sheet                     Value
  8232.            \softcol *        Special Characters              Flag
  8233.            \softlheight *    Special Characters              Value
  8234.            \softline *       Special Characters              Flag
  8235.            \softpage *       Special Characters              Flag
  8236.            \sprsspbf *       Document Formatting Properties  Flag
  8237.            \sprstsp *        Document Formatting Properties  Flag
  8238.            \strike           Character Formatting            Toggle
  8239.                              Properties
  8240.            \stylesheet       Style Sheet                     Destination
  8241.            \sub *            Character Formatting            Flag
  8242.                              Properties
  8243.            \subdocument *    Paragraph Formatting            Value
  8244.                              Properties
  8245.            \subject          Information Group               Destination
  8246.            \super *          Character Formatting            Flag
  8247.                              Properties
  8248.            \swpbdr *         Document Formatting Properties  Flag
  8249.            \tab              Special Characters              Symbol
  8250.  
  8251.  
  8252.  
  8253.                          Microsoft Product Support Services
  8254.  
  8255.  
  8256.                                                                     Page 135
  8257.  
  8258.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  8259.  
  8260.            Control word      Described in section            Type
  8261.            ---------------   ------------------------------  ---------------
  8262.            \tb               Tabs                            Value
  8263.            \tc               Table of Contents Entries       Destination
  8264.            \tcf              Table of Contents Entries       Value
  8265.            \tcl              Table of Contents Entries       Value
  8266.            \tcn *            Table of Contents Entries       Flag
  8267.            \template         Document Formatting Properties  Destination
  8268.            \title            Information Group               Destination
  8269.            \titlepg          Section Formatting Properties   Flag
  8270.            \tldot            Tabs                            Flag
  8271.            \tleq             Tabs                            Flag
  8272.            \tlhyph           Tabs                            Flag
  8273.            \tlth             Tabs                            Flag
  8274.            \tlul             Tabs                            Flag
  8275.            \tqc              Tabs                            Flag
  8276.            \tqdec            Tabs                            Flag
  8277.            \tqr              Tabs                            Flag
  8278.            \transmf *        Document Formatting Properties  Flag
  8279.            \trbrdrb *        Table Definitions               Flag
  8280.            \trbrdrh *        Table Definitions               Flag
  8281.            \trbrdrl *        Table Definitions               Flag
  8282.            \trbrdrr *        Table Definitions               Flag
  8283.            \trbrdrt *        Table Definitions               Flag
  8284.            \trbrdrv *        Table Definitions               Flag
  8285.            \trgaph           Table Definitions               Value
  8286.            \trhdr *          Table Definitions               Flag
  8287.            \trkeep *         Table Definitions               Flag
  8288.            \trleft           Table Definitions               Value
  8289.            \trowd            Table Definitions               Flag
  8290.            \trqc             Table Definitions               Flag
  8291.            \trql             Table Definitions               Flag
  8292.            \trqr             Table Definitions               Flag
  8293.            \trrh             Table Definitions               Value
  8294.            \tx               Tabs                            Value
  8295.            \txe              Index Entries                   Destination
  8296.            \ul               Character Formatting            Toggle
  8297.                              Properties
  8298.            \uld              Character Formatting            Flag
  8299.                              Properties
  8300.            \uldb             Character Formatting            Flag
  8301.                              Properties
  8302.            \ulnone           Character Formatting            Flag
  8303.                              Properties
  8304.            \ulw              Character Formatting            Flag
  8305.                              Properties
  8306.            \up               Character Formatting            Value
  8307.                              Properties
  8308.            \v                Character Formatting            Toggle
  8309.                              Properties
  8310.            \vern             Information Group               Value
  8311.            \version          Information Group               Value
  8312.            \vertalb          Section Formatting Properties   Flag
  8313.  
  8314.  
  8315.  
  8316.                          Microsoft Product Support Services
  8317.  
  8318.  
  8319.                                                                     Page 136
  8320.  
  8321.           Rich Text Format (RTF) Specification and Sample RTF Reader Program
  8322.  
  8323.            Control word      Described in section            Type
  8324.            ---------------   ------------------------------  ---------------
  8325.            \vertalc          Section Formatting Properties   Flag
  8326.            \vertalj          Section Formatting Properties   Flag
  8327.            \vertalt          Section Formatting Properties   Flag
  8328.            \wbitmap          Pictures                        Value
  8329.            \wbmbitspixel     Pictures                        Value
  8330.            \wbmplanes        Pictures                        Value
  8331.            \wbmwidthbytes    Pictures                        Value
  8332.            \widowctrl        Document Formatting Properties  Flag
  8333.            \wmetafile        Pictures                        Value
  8334.            \wraptrsp *       Document Formatting Properties  Flag
  8335.            \xe               Index Entries                   Destination
  8336.            \xef *            Index Entries                   Value
  8337.            \yr               Information Group               Value
  8338.            \zwj              Special Characters              Symbol
  8339.            \zwnj             Special Characters              Symbol
  8340.  
  8341.  
  8342.  
  8343.  
  8344.  
  8345.  
  8346.  
  8347.  
  8348.  
  8349.  
  8350.  
  8351.  
  8352.  
  8353.  
  8354.  
  8355.  
  8356.  
  8357.  
  8358.  
  8359.  
  8360.  
  8361.  
  8362.  
  8363.  
  8364.  
  8365.  
  8366.  
  8367.  
  8368.  
  8369.  
  8370.  
  8371.  
  8372.  
  8373.  
  8374.  
  8375.  
  8376.  
  8377.  
  8378.  
  8379.                          Microsoft Product Support Services
  8380.